Skip to content

Self-hosted project management for devs and their clients: tickets, time tracking, docs and meetings, with an AI assistant that cites its sources. AGPL-3.0.

merge: integrate REST ticket view and advance API to 1.4.0

Guido Boyke11fabaed5e4f
diff --cc .github/workflows/guards.yml
index 1c31792,502f9e6..b59f7c3
--- a/.github/workflows/guards.yml
+++ b/.github/workflows/guards.yml
@@@ -292,7 -292,7 +292,8 @@@ jobs
spec/requests/api/v1/error_codes_spec.rb
spec/requests/api/v1/idempotency_spec.rb
spec/requests/api/v1/capabilities_spec.rb
+ spec/requests/api/v1/time_session_booking_spec.rb
+ spec/requests/api/v1/ticket_view_spec.rb
spec/requests/api/v1/people_spec.rb
spec/requests/api/people_parity_spec.rb
spec/models/codebase_import_mapping_spec.rb
diff --cc CLAUDE.md
index 82dc77e,623db4a..e593bb2
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@@ -809,18 -810,27 +810,39 @@@ feature by feature)
pinned against the routes both ways (`spec/requests/api/v1/capabilities_spec.rb`): a new
endpoint adds its line there. Additive changes bump the minor.
+`POST /api/v1/tickets/:ticket_id/time_sessions` books by the rule the MCP tool
+`create_time_session` books by (REST R6, 2026-10-29; feature `time_sessions.book` in
+`/me`): `TimeSessions::Booking` refuses no duration, both `duration_string` and
+`duration_minutes`, `duration_minutes` that is no whole number, and an `occurred_on` that is
+no ISO 8601 date or timestamp (422
+`validation_failed`/`invalid_input`, inside the read gate), dates the booking as the
+calendar day in the token owner's profile zone (stored as midnight; absent = today there),
+and writes through `Actors::SaveTimeSession`; an unexpected actor failure (`internal_error`)
+answers 500 without its message. Rights stay in the controller. A booking
+writes no activity and no notification; it touches the ticket's `updated_at`. Guard:
+`spec/requests/api/v1/time_session_booking_spec.rb`.
+
+ **Ticket view** (REST R1, 2026-10-29, API 1.3.0):
+
+ * `GET /projects/:project_id/tickets` names `meta.available_statuses`, the project's status
+ keys from the same source as MCP `list_tickets`.
+ * `GET /tickets/:id` takes opt-in pages: any one of `posts_page`, `posts_per_page` (at most
+ 50, above is 422), `posts_order` (`oldest`, `newest`), `attachments_page` (10 per page)
+ switches the answer to the paged fields of MCP `get_ticket` (`posts_total`,
+ `posts_truncated`, `attachments`, ...). **Without them the body stays byte-equal** (the
+ contract records it; gboyke/lalabase-mcp reads it). Invalid values: 422 `invalid_input`,
+ checked before the ticket is looked up. A key without a value switches too. REST does not
+ truncate bodies, nor the extracted `text` of attachments (up to 10 per page). These
+ `attachments` are the ticket's own files only, with text and without URL (`attachments_total`
+ counts those); `GET /tickets/:id/attachments` lists ticket and comment files with signed URLs.
+ * `GET /projects/:project_id/tickets/number/:number` answers what `GET /tickets/:id` answers,
+ paging included. Missing, malformed (`abc`, `0`), unreadable, out of reach or foreign: the
+ same 404. The number is looked up only inside that project.
+ * `GET /tickets/:ticket_id/posts/:id`: one readable comment, whole, in the shape of a comment
+ in the ticket. Hidden private, foreign and missing comments: the same 404.
+ * Options and pages come from `Tickets::Reading`, shared with MCP `get_ticket`; MCP keeps its
+ caps. Guard: `spec/requests/api/v1/ticket_view_spec.rb`.
+
`GET /api/v1/time_sessions/open` lists the person's own open hours within the token's
reach, organisations AND projects, and only the rows the web time list shows them
(`TimeSessions::ViewingScope`). A booking on a ticket they cannot read keeps its row and
diff --cc app/services/api/v1/capabilities.rb
index ec85b4e,de3855f..a65aeca
--- a/app/services/api/v1/capabilities.rb
+++ b/app/services/api/v1/capabilities.rb
@@@ -15,8 -15,8 +15,9 @@@ module Ap
module Capabilities
# Minor for an additive change (a new endpoint, field or capability), major
# never: an existing name, field or meaning does not change. 1.2.0 added
- # people.list and people.show; 1.3.0 adds time_sessions.book.
- # the People API; 1.3.0 adds the REST ticket view (R1).
-- API_VERSION = '1.3.0'
++ # the People API; 1.3.0 added the REST ticket view (R1); 1.4.0 adds
++ # time_sessions.book (R6).
++ API_VERSION = '1.4.0'
# name => [verb, path as the router spells it]
ENDPOINTS = {
@@@ -44,10 -46,9 +47,10 @@@
# Abilities that are not one endpoint: `idempotency` (the Idempotency-Key
# header on every write, D7), `error_codes` (`code` on every error body, D6)
- # and `time_sessions.book` (time_sessions.create books by the rule the MCP
- # tool books by, TimeSessions::Booking: the day in the owner's zone, one
- # duration, unusable input refused; R6).
- FEATURES = %w[idempotency error_codes time_sessions.book].freeze
+ # and `tickets.paging` (the opt-in pages of comments and attachments on
- # tickets.show and tickets.by_number, R1).
- FEATURES = %w[idempotency error_codes tickets.paging].freeze
++ # tickets.show and tickets.by_number, R1), and `time_sessions.book`
++ # (shared duration/date validation and actor-backed booking, R6).
++ FEATURES = %w[idempotency error_codes tickets.paging time_sessions.book].freeze
def self.names
(ENDPOINTS.keys + FEATURES).sort
diff --cc spec/contracts/mcp_contract_recorder.rb
index f1f6456,6e98b1a..af98e1a
--- a/spec/contracts/mcp_contract_recorder.rb
+++ b/spec/contracts/mcp_contract_recorder.rb
@@@ -537,45 -537,11 +537,47 @@@ module McpContrac
# and the key reused with another body.
'errors' => rest_error_calls,
'idempotency' => rest_idempotency_calls,
- # People S3b: the directory of people_world, made before the MCP calls.
+ # People S3b, appended last: the directory of people_world, made before the MCP calls.
'GET /api/v1/organisations/:organisation_id/people' => rest_people_list_calls,
'GET /api/v1/organisations/:organisation_id/people/:id' => rest_people_show_calls,
+ # REST R1: the ticket view without MCP.
- 'ticket_view' => rest_ticket_view_calls
++ 'ticket_view' => rest_ticket_view_calls,
+ # REST R6 runs after the reads above, so its bookings do not change their answers.
+ 'POST /api/v1/tickets/:ticket_id/time_sessions' => rest_booking_calls
+ }
+ end
+
+ def rest_booking_calls
+ # Spelled out, not a loop: each request from its own line (Prosopite).
+ path = ->(ticket) { "/api/v1/tickets/#{id(ticket)}/time_sessions" }
+ login = path.call(:login_ticket)
+ once = { time_session: { duration_string: '0:15', description: 'Per REST, einmal.' } }
+ key = 'contract-rest-book-1'
+ {
+ 'ok_minutes_text' => rest_send(:post, :write, login, params: { time_session: { duration_string: '30' } }),
+ 'ok_hours_text' => rest_send(:post, :write, login,
+ params: { time_session: { duration_string: '1:30', occurred_on: '2026-01-04',
+ description: 'Vertrag' } }),
+ 'ok_minutes' => rest_send(:post, :write, login, params: { time_session: { duration_minutes: 45 } }),
+ 'invalid_input_no_duration' => rest_send(:post, :write, login, params: { time_session: { description: 'x' } }),
+ 'invalid_input_both_durations' => rest_send(:post, :write, login,
+ params: { time_session: { duration_string: '30',
+ duration_minutes: 30 } }),
+ 'invalid_input_date' => rest_send(:post, :write, login,
+ params: { time_session: { duration_string: '30', occurred_on: '05.01.2026' } }),
+ 'invalid_input_over_a_day' => rest_send(:post, :write, login, params: { time_session: { duration_string: '24:01' } }),
+ 'not_found' => rest_send(:post, :write, path.call(:missing), params: { time_session: { duration_string: '30' } }),
+ # No read access to the ticket: answered like a missing one.
+ 'hidden' => rest_send(:post, :write, path.call(:hidden_ticket), params: { time_session: { duration_string: '30' } }),
+ # Anna reads the archive's tickets but has no time right there.
+ 'forbidden' => rest_send(:post, :write, path.call(:archived_ticket),
+ params: { time_session: { duration_string: '30' } }),
+ 'read_only' => rest_send(:post, :read, login, params: { time_session: { duration_string: '30' } }),
+ 'idempotency_first' => rest_send(:post, :write, login, params: once, key: key),
+ 'idempotency_replay' => rest_send(:post, :write, login, params: once, key: key),
+ 'idempotency_mismatch' => rest_send(:post, :write, login, params: { time_session: { duration_string: '0:20' } },
+ key: key),
+ 'invalid_input_minutes' => rest_send(:post, :write, login, params: { time_session: { duration_minutes: '1.5' } })
}
end
diff --cc spec/fixtures/mcp_contract.json
index 5a7a81e,c00a714..400a067
--- a/spec/fixtures/mcp_contract.json
+++ b/spec/fixtures/mcp_contract.json
@@@ -1,9 -1,9 +1,9 @@@
{
"header": {
"regenerate": "RAILS_ENV=test bin/rails mcp:contract",
- "core_commit": "ac4a327109ba1c2002d9d11de87ca8c1afbbc175",
- "core_commit": "ce61484a85f94780cb44905b9389cdc6ef12b8c4",
++ "core_commit": "8da6fd8e1a6e30aec8fa2620118017cf36b68d97",
"core_dirty": true,
- "contract_sha256": "769d6cf508f18e725ff509b17209895f01d536703266190ebdb9c2742905a4d7"
- "contract_sha256": "02d0ae3f56e787d7af48dc78b2fd116d45481737e099fe433e071c6ef51f3316"
++ "contract_sha256": "1ef1b7500cbe132f2917f4943c225aa9de71903b821aab523484bc6a032ac7a7"
},
"contract": {
"mcp": {
@@@ -3654,7 -3654,7 +3654,7 @@@
"all_projects": true
}
],
-- "api_version": "1.3.0",
++ "api_version": "1.4.0",
"capabilities": [
"error_codes",
"idempotency",
@@@ -3671,11 -3672,12 +3672,13 @@@
"projects.ticket_attribute_definitions",
"tickets.activities",
"tickets.attachments",
+ "tickets.by_number",
"tickets.create",
"tickets.list",
+ "tickets.paging",
"tickets.show",
"tickets.update",
+ "time_sessions.book",
"time_sessions.create",
"time_sessions.list",
"time_sessions.open"
@@@ -3714,7 -3716,7 +3717,7 @@@
"all_projects": true
}
],
-- "api_version": "1.3.0",
++ "api_version": "1.4.0",
"capabilities": [
"error_codes",
"idempotency",
@@@ -3731,11 -3734,12 +3735,13 @@@
"projects.ticket_attribute_definitions",
"tickets.activities",
"tickets.attachments",
+ "tickets.by_number",
"tickets.create",
"tickets.list",
+ "tickets.paging",
"tickets.show",
"tickets.update",
+ "time_sessions.book",
"time_sessions.create",
"time_sessions.list",
"time_sessions.open"
@@@ -4597,382 -4601,404 +4603,781 @@@
}
}
},
+ "ticket_view": {
+ "list": {
+ "token": "read",
+ "request": {
+ "path": "/api/v1/projects/00000000-0000-4000-8000-000000000031/tickets?assignee=00000000-0000-4000-8000-000000000012"
+ },
+ "response": {
+ "status": 200,
+ "body": {
+ "data": [
+ {
+ "id": "00000000-0000-4000-8000-000000000041",
+ "number": 1,
+ "title": "Login bricht ab",
+ "status": "in_progress",
+ "status_functions": [
+ "is_in_progress"
+ ],
+ "ticket_type": "support",
+ "parent_id": null,
+ "assignees": [
+ {
+ "id": "00000000-0000-4000-8000-000000000011",
+ "name": "Anna Albers"
+ },
+ {
+ "id": "00000000-0000-4000-8000-000000000012",
+ "name": "Ben Berger"
+ },
+ {
+ "id": "00000000-0000-4000-8000-000000000013",
+ "name": "Carla Conrad"
+ }
+ ],
+ "creator": {
+ "id": "00000000-0000-4000-8000-000000000011",
+ "name": "Anna Albers"
+ },
+ "created_at": "2026-01-05T09:21:00Z",
+ "updated_at": "2026-01-05T09:36:00Z"
+ }
+ ],
+ "meta": {
+ "page": 1,
+ "per_page": 25,
+ "total": 1,
+ "available_statuses": [
+ "new",
+ "in_progress",
+ "resolved",
+ "closed",
+ "backlog"
+ ]
+ }
+ }
+ }
+ },
+ "show": {
+ "token": "read",
+ "request": {
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000042"
+ },
+ "response": {
+ "status": 200,
+ "body": {
+ "data": {
+ "id": "00000000-0000-4000-8000-000000000042",
+ "number": 2,
+ "title": "Export als CSV und XLSX",
+ "status": "in_progress",
+ "status_functions": [
+ "is_in_progress"
+ ],
+ "ticket_type": "support",
+ "parent_id": null,
+ "assignees": [
+ {
+ "id": "00000000-0000-4000-8000-000000000011",
+ "name": "Anna Albers"
+ }
+ ],
+ "creator": {
+ "id": "00000000-0000-4000-8000-000000000012",
+ "name": "Ben Berger"
+ },
+ "created_at": "2026-01-05T09:22:00Z",
+ "updated_at": "2026-01-05T09:36:00Z",
+ "summary": null,
+ "description_html": "Spalten wie in der Liste.",
+ "description_text": "Spalten wie in der Liste.",
+ "custom_attributes": {
+ "status": "in_progress",
+ "priority": "normal"
+ },
+ "project": {
+ "id": "00000000-0000-4000-8000-000000000031",
+ "name": "Website-Relaunch"
+ },
+ "posts": []
+ },
+ "permissions": {
+ "is_account_admin": false,
+ "tickets": {
+ "read": true,
+ "write": true
+ },
+ "documents": {
+ "read": false,
+ "write": false
+ },
+ "posts": {
+ "can_create": true,
+ "can_update_own": true,
+ "can_destroy_own": true
+ },
+ "time_sessions": {
+ "can_view_own": true,
+ "can_view_all": false,
+ "can_create_own": true,
+ "can_edit_own": true,
+ "can_edit_all": false,
+ "can_delete_own": true,
+ "can_delete_all": false
+ },
+ "activities": {
+ "read": true
+ }
+ }
+ }
+ }
+ },
+ "show_paged": {
+ "token": "read",
+ "request": {
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041?posts_per_page=1&posts_page=2&attachments_page=1"
+ },
+ "response": {
+ "status": 200,
+ "body": {
+ "data": {
+ "id": "00000000-0000-4000-8000-000000000041",
+ "number": 1,
+ "title": "Login bricht ab",
+ "status": "in_progress",
+ "status_functions": [
+ "is_in_progress"
+ ],
+ "ticket_type": "support",
+ "parent_id": null,
+ "assignees": [
+ {
+ "id": "00000000-0000-4000-8000-000000000011",
+ "name": "Anna Albers"
+ },
+ {
+ "id": "00000000-0000-4000-8000-000000000012",
+ "name": "Ben Berger"
+ },
+ {
+ "id": "00000000-0000-4000-8000-000000000013",
+ "name": "Carla Conrad"
+ }
+ ],
+ "creator": {
+ "id": "00000000-0000-4000-8000-000000000011",
+ "name": "Anna Albers"
+ },
+ "created_at": "2026-01-05T09:21:00Z",
+ "updated_at": "2026-01-05T09:36:00Z",
+ "summary": null,
+ "description_html": "Nach dem Absenden bleibt die Seite weiß.",
+ "description_text": "Nach dem Absenden bleibt die Seite weiß.",
+ "custom_attributes": {
+ "status": "in_progress",
+ "priority": "high"
+ },
+ "project": {
+ "id": "00000000-0000-4000-8000-000000000031",
+ "name": "Website-Relaunch"
+ },
+ "posts": [
+ {
+ "id": "00000000-0000-4000-8000-000000000052",
+ "author": {
+ "id": "00000000-0000-4000-8000-000000000011",
+ "name": "Anna Albers"
+ },
+ "body_html": "Ich schaue es mir an.",
+ "body_text": "Ich schaue es mir an.",
+ "is_private": false,
+ "attachments_count": 0,
+ "created_at": "2026-01-05T09:26:00Z",
+ "updated_at": "2026-01-05T09:26:00Z"
+ }
+ ],
+ "posts_total": 7,
+ "posts_truncated": true,
+ "posts_page": 2,
+ "posts_per_page": 1,
+ "posts_pages": 7,
+ "posts_order": "oldest",
+ "attachments": [
+ {
+ "id": "<generated-id-8>",
+ "filename": "test_document.pdf",
+ "content_type": "application/pdf",
+ "byte_size": 452,
+ "text": null,
+ "text_status": "unavailable"
+ }
+ ],
+ "attachments_total": 1,
+ "attachments_truncated": false,
+ "attachments_page": 1,
+ "attachments_pages": 1
+ },
+ "permissions": {
+ "is_account_admin": false,
+ "tickets": {
+ "read": true,
+ "write": true
+ },
+ "documents": {
+ "read": false,
+ "write": false
+ },
+ "posts": {
+ "can_create": true,
+ "can_update_own": true,
+ "can_destroy_own": true
+ },
+ "time_sessions": {
+ "can_view_own": true,
+ "can_view_all": false,
+ "can_create_own": true,
+ "can_edit_own": true,
+ "can_edit_all": false,
+ "can_delete_own": true,
+ "can_delete_all": false
+ },
+ "activities": {
+ "read": true
+ }
+ }
+ }
+ }
+ },
+ "show_invalid_paging": {
+ "token": "read",
+ "request": {
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041?posts_order=random"
+ },
+ "response": {
+ "status": 422,
+ "body": {
+ "error": "invalid_input",
+ "code": "invalid_input",
+ "message": "invalid posts_order \"random\" (oldest or newest)"
+ }
+ }
+ },
+ "by_number": {
+ "token": "read",
+ "request": {
+ "path": "/api/v1/projects/00000000-0000-4000-8000-000000000031/tickets/number/2"
+ },
+ "response": {
+ "status": 200,
+ "body": {
+ "data": {
+ "id": "00000000-0000-4000-8000-000000000042",
+ "number": 2,
+ "title": "Export als CSV und XLSX",
+ "status": "in_progress",
+ "status_functions": [
+ "is_in_progress"
+ ],
+ "ticket_type": "support",
+ "parent_id": null,
+ "assignees": [
+ {
+ "id": "00000000-0000-4000-8000-000000000011",
+ "name": "Anna Albers"
+ }
+ ],
+ "creator": {
+ "id": "00000000-0000-4000-8000-000000000012",
+ "name": "Ben Berger"
+ },
+ "created_at": "2026-01-05T09:22:00Z",
+ "updated_at": "2026-01-05T09:36:00Z",
+ "summary": null,
+ "description_html": "Spalten wie in der Liste.",
+ "description_text": "Spalten wie in der Liste.",
+ "custom_attributes": {
+ "status": "in_progress",
+ "priority": "normal"
+ },
+ "project": {
+ "id": "00000000-0000-4000-8000-000000000031",
+ "name": "Website-Relaunch"
+ },
+ "posts": []
+ },
+ "permissions": {
+ "is_account_admin": false,
+ "tickets": {
+ "read": true,
+ "write": true
+ },
+ "documents": {
+ "read": false,
+ "write": false
+ },
+ "posts": {
+ "can_create": true,
+ "can_update_own": true,
+ "can_destroy_own": true
+ },
+ "time_sessions": {
+ "can_view_own": true,
+ "can_view_all": false,
+ "can_create_own": true,
+ "can_edit_own": true,
+ "can_edit_all": false,
+ "can_delete_own": true,
+ "can_delete_all": false
+ },
+ "activities": {
+ "read": true
+ }
+ }
+ }
+ }
+ },
+ "by_number_not_found": {
+ "token": "read",
+ "request": {
+ "path": "/api/v1/projects/00000000-0000-4000-8000-000000000031/tickets/number/999"
+ },
+ "response": {
+ "status": 404,
+ "body": {
+ "error": "not_found",
+ "code": "not_found"
+ }
+ }
+ },
+ "by_number_hidden": {
+ "token": "read",
+ "request": {
+ "path": "/api/v1/projects/00000000-0000-4000-8000-000000000033/tickets/number/1"
+ },
+ "response": {
+ "status": 404,
+ "body": {
+ "error": "not_found",
+ "code": "not_found"
+ }
+ }
+ },
+ "post": {
+ "token": "read",
+ "request": {
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/posts/00000000-0000-4000-8000-000000000051"
+ },
+ "response": {
+ "status": 200,
+ "body": {
+ "data": {
+ "id": "00000000-0000-4000-8000-000000000051",
+ "author": {
+ "id": "00000000-0000-4000-8000-000000000012",
+ "name": "Ben Berger"
+ },
+ "body_html": "Tritt nur in Safari auf.",
+ "body_text": "Tritt nur in Safari auf.",
+ "is_private": false,
+ "attachments_count": 1,
+ "created_at": "2026-01-05T09:25:00Z",
+ "updated_at": "2026-01-05T09:36:00Z"
+ }
+ }
+ }
+ },
+ "post_not_found": {
+ "token": "read",
+ "request": {
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/posts/00000000-0000-4000-8000-000000000999"
+ },
+ "response": {
+ "status": 404,
+ "body": {
+ "error": "not_found",
+ "code": "not_found"
+ }
+ }
+ }
++ },
+ "POST /api/v1/tickets/:ticket_id/time_sessions": {
+ "ok_minutes_text": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/time_sessions",
+ "params": {
+ "time_session": {
+ "duration_string": "30"
+ }
+ }
+ },
+ "response": {
+ "status": 201,
+ "body": {
+ "data": {
- "id": "<generated-id-8>",
++ "id": "<generated-id-9>",
+ "ticket_id": "00000000-0000-4000-8000-000000000041",
+ "creator": {
+ "id": "00000000-0000-4000-8000-000000000011",
+ "name": "Anna Albers"
+ },
+ "occurred_on": "2026-01-05T00:00:00Z",
+ "duration_minutes": 30,
+ "description": null,
+ "customer_description": null,
+ "billed": false,
+ "billed_at": null,
+ "created_at": "2026-01-05T09:36:00Z"
+ }
+ }
+ }
+ },
+ "ok_hours_text": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/time_sessions",
+ "params": {
+ "time_session": {
+ "duration_string": "1:30",
+ "occurred_on": "2026-01-04",
+ "description": "Vertrag"
+ }
+ }
+ },
+ "response": {
+ "status": 201,
+ "body": {
+ "data": {
- "id": "<generated-id-9>",
++ "id": "<generated-id-10>",
+ "ticket_id": "00000000-0000-4000-8000-000000000041",
+ "creator": {
+ "id": "00000000-0000-4000-8000-000000000011",
+ "name": "Anna Albers"
+ },
+ "occurred_on": "2026-01-04T00:00:00Z",
+ "duration_minutes": 90,
+ "description": "Vertrag",
+ "customer_description": null,
+ "billed": false,
+ "billed_at": null,
+ "created_at": "2026-01-05T09:36:00Z"
+ }
+ }
+ }
+ },
+ "ok_minutes": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/time_sessions",
+ "params": {
+ "time_session": {
+ "duration_minutes": 45
+ }
+ }
+ },
+ "response": {
+ "status": 201,
+ "body": {
+ "data": {
- "id": "<generated-id-10>",
++ "id": "<generated-id-11>",
+ "ticket_id": "00000000-0000-4000-8000-000000000041",
+ "creator": {
+ "id": "00000000-0000-4000-8000-000000000011",
+ "name": "Anna Albers"
+ },
+ "occurred_on": "2026-01-05T00:00:00Z",
+ "duration_minutes": 45,
+ "description": null,
+ "customer_description": null,
+ "billed": false,
+ "billed_at": null,
+ "created_at": "2026-01-05T09:36:00Z"
+ }
+ }
+ }
+ },
+ "invalid_input_no_duration": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/time_sessions",
+ "params": {
+ "time_session": {
+ "description": "x"
+ }
+ }
+ },
+ "response": {
+ "status": 422,
+ "body": {
+ "error": "validation_failed",
+ "code": "invalid_input",
+ "errors": [
+ "Bitte geben Sie eine Dauer an (duration_string oder duration_minutes)."
+ ]
+ }
+ }
+ },
+ "invalid_input_both_durations": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/time_sessions",
+ "params": {
+ "time_session": {
+ "duration_string": "30",
+ "duration_minutes": 30
+ }
+ }
+ },
+ "response": {
+ "status": 422,
+ "body": {
+ "error": "validation_failed",
+ "code": "invalid_input",
+ "errors": [
+ "Bitte geben Sie die Dauer entweder als duration_string oder als duration_minutes an, nicht beides."
+ ]
+ }
+ }
+ },
+ "invalid_input_date": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/time_sessions",
+ "params": {
+ "time_session": {
+ "duration_string": "30",
+ "occurred_on": "05.01.2026"
+ }
+ }
+ },
+ "response": {
+ "status": 422,
+ "body": {
+ "error": "validation_failed",
+ "code": "invalid_input",
+ "errors": [
+ "Das Datum (occurred_on) ist kein ISO-8601-Datum und kein ISO-8601-Zeitstempel."
+ ]
+ }
+ }
+ },
+ "invalid_input_over_a_day": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/time_sessions",
+ "params": {
+ "time_session": {
+ "duration_string": "24:01"
+ }
+ }
+ },
+ "response": {
+ "status": 422,
+ "body": {
+ "error": "validation_failed",
+ "code": "invalid_input",
+ "errors": [
+ "Dauer darf höchstens 1440 Minuten (24 Stunden) betragen"
+ ]
+ }
+ }
+ },
+ "not_found": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000999/time_sessions",
+ "params": {
+ "time_session": {
+ "duration_string": "30"
+ }
+ }
+ },
+ "response": {
+ "status": 404,
+ "body": {
+ "error": "not_found",
+ "code": "not_found"
+ }
+ }
+ },
+ "hidden": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000043/time_sessions",
+ "params": {
+ "time_session": {
+ "duration_string": "30"
+ }
+ }
+ },
+ "response": {
+ "status": 404,
+ "body": {
+ "error": "not_found",
+ "code": "not_found"
+ }
+ }
+ },
+ "forbidden": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000044/time_sessions",
+ "params": {
+ "time_session": {
+ "duration_string": "30"
+ }
+ }
+ },
+ "response": {
+ "status": 403,
+ "body": {
+ "error": "forbidden",
+ "code": "forbidden"
+ }
+ }
+ },
+ "read_only": {
+ "token": "read",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/time_sessions",
+ "params": {
+ "time_session": {
+ "duration_string": "30"
+ }
+ }
+ },
+ "response": {
+ "status": 403,
+ "body": {
+ "error": "forbidden",
+ "code": "read_only"
+ }
+ }
+ },
+ "idempotency_first": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/time_sessions",
+ "params": {
+ "time_session": {
+ "duration_string": "0:15",
+ "description": "Per REST, einmal."
+ }
+ },
+ "idempotency_key": "contract-rest-book-1"
+ },
+ "response": {
+ "status": 201,
+ "body": {
+ "data": {
- "id": "<generated-id-11>",
++ "id": "<generated-id-12>",
+ "ticket_id": "00000000-0000-4000-8000-000000000041",
+ "creator": {
+ "id": "00000000-0000-4000-8000-000000000011",
+ "name": "Anna Albers"
+ },
+ "occurred_on": "2026-01-05T00:00:00Z",
+ "duration_minutes": 15,
+ "description": "Per REST, einmal.",
+ "customer_description": null,
+ "billed": false,
+ "billed_at": null,
+ "created_at": "2026-01-05T09:36:00Z"
+ }
+ }
+ }
+ },
+ "idempotency_replay": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/time_sessions",
+ "params": {
+ "time_session": {
+ "duration_string": "0:15",
+ "description": "Per REST, einmal."
+ }
+ },
+ "idempotency_key": "contract-rest-book-1"
+ },
+ "response": {
+ "status": 201,
+ "body": {
+ "data": {
- "id": "<generated-id-11>",
++ "id": "<generated-id-12>",
+ "ticket_id": "00000000-0000-4000-8000-000000000041",
+ "creator": {
+ "id": "00000000-0000-4000-8000-000000000011",
+ "name": "Anna Albers"
+ },
+ "occurred_on": "2026-01-05T00:00:00Z",
+ "duration_minutes": 15,
+ "description": "Per REST, einmal.",
+ "customer_description": null,
+ "billed": false,
+ "billed_at": null,
+ "created_at": "2026-01-05T09:36:00Z"
+ }
+ }
+ }
+ },
+ "idempotency_mismatch": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/time_sessions",
+ "params": {
+ "time_session": {
+ "duration_string": "0:20"
+ }
+ },
+ "idempotency_key": "contract-rest-book-1"
+ },
+ "response": {
+ "status": 422,
+ "body": {
+ "error": "idempotency_key_reused",
+ "code": "invalid_input",
+ "message": "idempotency_key already used with different parameters"
+ }
+ }
+ },
+ "invalid_input_minutes": {
+ "token": "write",
+ "request": {
+ "method": "POST",
+ "path": "/api/v1/tickets/00000000-0000-4000-8000-000000000041/time_sessions",
+ "params": {
+ "time_session": {
+ "duration_minutes": "1.5"
+ }
+ }
+ },
+ "response": {
+ "status": 422,
+ "body": {
+ "error": "validation_failed",
+ "code": "invalid_input",
+ "errors": [
+ "Bitte geben Sie duration_minutes als ganze Zahl von Minuten an."
+ ]
+ }
+ }
+ }
}
}
}
diff --cc spec/requests/api/v1/capabilities_spec.rb
index a38ba6d,65d9e2b..46fa5c8
--- a/spec/requests/api/v1/capabilities_spec.rb
+++ b/spec/requests/api/v1/capabilities_spec.rb
@@@ -33,7 -33,7 +33,7 @@@ RSpec.describe 'API V1 capabilities', :
it 'names the API version and the capabilities beside the existing fields' do
data = me(token(read_only: false))
-- expect(data['api_version']).to eq('1.3.0')
++ expect(data['api_version']).to eq('1.4.0')
expect(data['capabilities']).to eq(Api::V1::Capabilities.names)
expect(data.keys).to include('user', 'token', 'scoped_organisations')
end
@@@ -47,7 -47,7 +47,7 @@@
'me.show', 'organisations.list', 'projects.list', 'tickets.list', 'tickets.create', 'tickets.show',
'tickets.update', 'tickets.attachments', 'posts.create', 'time_sessions.create',
'notifications.list', 'notifications.mark_as_read', 'people.list', 'people.show', 'idempotency', 'error_codes',
- 'time_sessions.book'
- 'tickets.by_number', 'posts.show', 'tickets.paging'
++ 'tickets.by_number', 'posts.show', 'tickets.paging', 'time_sessions.book'
)
end