Skip to content

Latest commit

 

History

History
186 lines (135 loc) · 3.31 KB

File metadata and controls

186 lines (135 loc) · 3.31 KB

Create User Calendar

Creates a new calendar for a specific user.

URL : /api/v1/calendars/:user_id/create

Method : POST

Auth required : YES

Params constraints

:user_id -> "[user id as an int]",

Request Body constraints

{
	"name": "[string: calendar name, alphanumeric, spaces, underscores and hyphens, max 64 chars]",
	"uri": "[string: calendar URI, lowercase alphanumeric, underscores and hyphens, max 128 chars]",
	"description": "[string: calendar description, alphanumeric, spaces, underscores and hyphens, max 256 chars, optional]",
	"events_support": "[string: 'true' or 'false', default 'true', optional]",
	"notes_support": "[string: 'true' or 'false', default 'false', optional]",
	"tasks_support": "[string: 'true' or 'false', default 'false', optional]"
}

URL example

/api/v1/calendars/jdoe/create

Body example

{
	"name": "Work Calendar",
	"uri": "work-calendar",
	"description": "Calendar for work events",
	"events_support": "true",
	"notes_support": "false",
	"tasks_support": "true"
}

Success Response

Code : 200 OK

Content examples

{
	"status": "success",
	"data": {
		"calendar_id": 5,
		"calendar_uri": "work-calendar"
	},
	"timestamp": "2026-01-23T15:01:33+01:00"
}

Error Response

Condition : If 'X-Davis-API-Token' is not present or mismatched in headers.

Code : 401 UNAUTHORIZED

Content :

{
	"message": "No API token provided",
	"timestamp": "2026-01-23T15:01:33+01:00"
}

or

{
	"message": "Invalid API token",
	"timestamp": "2026-01-23T15:01:33+01:00"
}

Condition : If user is not found.

Code : 404 NOT FOUND

Content :

{
	"status": "error",
	"message": "User Not Found",
	"timestamp": "2026-01-23T15:01:33+01:00"
}

Condition : If request body contains invalid JSON.

Code : 400 BAD REQUEST

Content :

{
	"status": "error",
	"message": "Invalid JSON",
	"timestamp": "2026-01-23T15:01:33+01:00"
}

Condition : If 'name' parameter is invalid (not matching the regex or exceeds length).

Code : 400 BAD REQUEST

Content :

{
	"status": "error",
	"message": "Invalid Calendar Name",
	"timestamp": "2026-01-23T15:01:33+01:00"
}

Condition : If 'uri' parameter is invalid (not matching the regex or exceeds length).

Code : 400 BAD REQUEST

Content :

{
	"status": "error",
	"message": "Invalid Calendar URI",
	"timestamp": "2026-01-23T15:01:33+01:00"
}

Condition : If calendar with specified URI already exists for the user.

Code : 400 BAD REQUEST

Content :

{
	"status": "error",
	"message": "Calendar URI Already Exists",
	"timestamp": "2026-01-23T15:01:33+01:00"
}

Condition : If 'description' parameter is invalid (not matching the regex or exceeds length).

Code : 400 BAD REQUEST

Content :

{
	"status": "error",
	"message": "Invalid Calendar Description",
	"timestamp": "2026-01-23T15:01:33+01:00"
}

Condition : If no calendar components are enabled (all of events_support, notes_support, and tasks_support are false).

Code : 400 BAD REQUEST

Content :

{
	"status": "error",
	"message": "At least one calendar component must be enabled (events, notes, or tasks)",
	"timestamp": "2026-01-23T15:01:33+01:00"
}