Skip to content

Routine API Integration #175

@dhakar66

Description

@dhakar66

Implement POST /routines — Create Routine with First Time Block

Endpoint

POST /api/v1/routines (Bearer JWT auth)

What it does

Creates a new routine for the authenticated user along with the first time block and its sessions. Used when no routine exists yet for the user.

Request Body (CreateTimeBlockRequest)

{
  "time": "06:00",
  "time_int": 600,
  "notification_enabled": true,
  "sessions": [
    {
      "session_type": "PLAN",
      "source_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "display_order": 0
    }
  ]
}

Success Response — 201

Returns RoutineWithTimeBlocksResponse:

{
  "id": "routine-uuid",
  "time_blocks": [
    {
      "id": "time-block-uuid",
      "time": "06:00",
      "time_int": 600,
      "notification_enabled": true,
      "sessions": [
        {
          "id": "session-uuid",
          "session_type": "PLAN",
          "source_id": "a1b2c3d4-...",
          "title": "AIY - Introduction",
          "language": "en",
          "image_url": "https://...",
          "display_order": 0
        }
      ]
    }
  ]
}

Error Responses

Code Meaning
401 Invalid/missing JWT
409 Routine already exists for this user
422 Validation error (no sessions, duplicate plan, bad time format)

Validation Rules

  • Must have at least one session
  • A plan source_id can only appear once across the entire routine
  • time must be valid HH:MM 24-hour format (00:00–23:59)
  • session_type is either PLAN or RECITATION

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

Status

IN PROGRESS

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions