Notes API
General notes
Embeddable fields
| Name | Type | Description |
|---|---|---|
noteable | User/Client | Model of noteable. |
user | User | Array of custom fields for task User. |
Content
Notes collection:
Single note:
Clients collection
Clients index
This method needs permission
accessonnotes.
Request
| Index behaviour | Definition |
|---|---|
| Paginated by default | No |
| Sorting | id, noteable_type, noteable_id, text, user_id, created_at, updated_at |
| Filters | id:enum, noteable_type:string, noteable_id:int, text:string, user_id: int, created_at: date, updated_at: date |
| Embedded | - |
GET /api/v0/notes HTTP/1.1
Content-Type: application/json
Response
200 OK
GET /api/v0/notes HTTP/1.1
Content-Type: application/json
{
"items": [
{
"id": 1,
"noteable_type": "App\\Containers\\Users\\Users\\Models\\User",
"noteable_id": 2,
"text": "test poznamky",
"user_id": 1,
"created_at": "2023-01-05T15:35:48+0100",
"updated_at": "2023-01-05T15:35:48+0100",
"_links": [
{
"href": "/api/v0/notes/1",
"rel": "self",
"type": "GET"
}
]
},
{
"id": 2,
"noteable_type": "App\\Containers\\Users\\Users\\Models\\User",
"noteable_id": 2,
"text": "test poznamky 2",
"user_id": 1,
"created_at": "2023-01-05T15:37:12+0100",
"updated_at": "2023-01-05T15:37:12+0100",
"_links": [
{
"href": "/api/v0/notes/2",
"rel": "self",
"type": "GET"
}
]
},
]
}
Single note
Note detail
GET /api/v0/notes/{note_id}
This method needs permission
readonnotes.
Get Note detail.
Request
| Index behaviour | Definition |
|---|---|
| Embedded | - |
Request
GET /api/v0/notes/1 HTTP/1.1
Content-Type: application/json
Response
200 OK
GET /api/v0/notes/1 HTTP/1.1
Content-Type: application/json
{
"id": 1,
"noteable_type": "App\\Containers\\Users\\Users\\Models\\User",
"noteable_id": 2,
"text": "test poznamky",
"user_id": 1,
"created_at": "2023-01-05T15:35:48+0100",
"updated_at": "2023-01-05T15:35:48+0100",
"_links": [
{
"href": "/api/v0/notes/1",
"rel": "self",
"type": "GET"
}
]
}
404 NOT FOUND
Note was not found.
GET /api/v0/notes/10 HTTP/1.1
Content-Type: application/json
Status-Code: 404
{
"type": "NotFound",
"message": "Required model was not found.",
"id": "0cd85449-05fe-4866-9802-8192e6785fc7"
}
Update Note
PUT/PATCH /api/v0/notes/{note_id}
This method needs permission
updateonnotes.
Method for updating Note data.
Request
| Param | Type | Description | Requirements |
|---|---|---|---|
text | string | Note text | Sometimes. Has to be string. |
user_id | int | Note's author User id | Sometimes. Has to be int. |
For PATCH method any field can be omitted.
PATCH /api/v0/notes/1 HTTP/1.1
Content-Type: application/json
{
"text": "Demo note",
}
Response
200 OK
Note successfully updated.
PATCH /api/notes/3 HTTP/1.1
Content-Type: application/json
{
"id": 1,
"noteable_type": "App\\Containers\\Users\\Users\\Models\\User",
"noteable_id": 2,
"text": "Note update text",
"user_id": 1,
"created_at": "2023-01-05T15:35:48+0100",
"updated_at": "2023-01-06T11:11:51+0100",
"_links": [
{
"href": "/api/v0/notes/1",
"rel": "self",
"type": "GET"
}
]
}
404 NOT FOUND
Note was not found.
PATCH /api/notes/2 HTTP/1.1
Content-Type: application/json
Status-Code: 404
{
"type": "NotFound",
"message": "Required model was not found.",
"id": "0cd85449-05fe-4866-9802-8192e6785fc7"
}
422 UNPROCESSABLE ENTITY
Validation error occurred.
PUT /api/notes HTTP/1.1
Content-Type: application/json
{
"type" : "ValidationError",
"message" : "The given data was invalid.",
"id" : "fe1b04de-b347-43b5-8118-864c1eefaccf",
"errors": [
{
"field": "text",
"message": "The name field is required."
}
]
}
Delete Note
DELETE /api/v0/notes/{note_id}
This method needs permission
deleteonnotes.
Method for deleting Note.
Request
DELETE /api/v0/notes/1 HTTP/1.1
Response
200 OK
Note successfully updated.
PATCH /api/notes/3 HTTP/1.1
Content-Type: application/json
{
"id": 1,
"noteable_type": "App\\Containers\\Users\\Users\\Models\\User",
"noteable_id": 2,
"text": "Note update text",
"user_id": 1,
"created_at": "2023-01-05T15:35:48+0100",
"updated_at": "2023-01-06T11:11:51+0100",
"_links": [
{
"href": "/api/v0/notes/1",
"rel": "self",
"type": "GET"
}
]
}