TODODescribe a{%feature%}here ...
TODO
- replace all placeholders {%placeholder%} with appropriate values.
{text}is not a placeholder (single brackets).- Do not remove `` chars if placeholder is between them, like
{%placeholder%}.- Extend descriptions if needed.
- Remove this (and others) TODO block - it's just a guide.
Permissions
TODOplease describe permissions, including from what they come, like some permission sets, etc.
Permissions for {%feature%} can be checked by:
| Context | Endpoint | Location | Available perms |
|---|---|---|---|
| Global scope | GET /api/users/permissions/ | {%resource%} | {%perm%}, {%perm%} |
| Specific | GET /{%endpoint%}/ | _meta.permissions.{%resource%} | {%perm%}, {%perm%} |
References
POST /{%endpoint%}/
Creates {%object_name%}.
Permissions
Requires authentication and {%resource%}.{%perm%} permission.
Request
- URL parameters
| Key | Type | Notes |
|---|---|---|
| uuid | uuid |
- Body parameters
| Key | Type | Notes |
|---|---|---|
- Headers
Content-Type: application/json
Authorization: JWT access_token- Schema
POST /{%endpoint%}/
{
"{%attribute%}": "{%str_value%}",
"{%attribute%}": {%int_bool_value%}
}Validations
- Max length: 100 (
TODOit's a sample, remove if not relevant) - {%validation%}:
- Max length: 100 (
Restrictions
TODOplease describe limits enforced by the endpoint.
Response
TODOin table below there isuuid. Probably all new endpoints will use it instead of integerid.
TODOplease remove non-matching attributes.
| Key | Type | Notes |
|---|---|---|
| uuid | uuid | Automatically generated by the backend. |
| created_at | datetime | |
| created_by | user | |
| modified_at | datetime | |
| modified_by | user | |
| _meta.labels | Object | Object containing labels for attributes. |
| _meta.permissions | Object | Object describing permissions. |
- Successful status
201 Created - Response body schema
{
"uuid": <uuid>,
"{%attribute%}": {%type%},
...
"created_at": <datetime>,
"created_by": <user>,
"modified_at": <datetime>,
"modified_by": <user>,
"_meta": {
"labels": {
"{%attribute%}": <string>,
...
},
"permissions": {
"{%perm%}": <bool>,
...
}
}
}Errors
| Cause | Response code | Message |
|---|---|---|
| "{%attribute%}" is missing | 400 Bad Request | "name": ["This field is required."] |
| "{%attribute%}" is empty string | 400 Bad Request | "name": ["This field may not be blank."] |
| "{%attribute%}" is null | 400 Bad Request | "name": ["This field may not be null."] |
| "{%attribute%}" has > {%limit%} chars | 400 Bad Request | "name": ["Ensure this field has no more than {%limit%} characters."] |
| "{%attribute%}" is not unique | 400 Bad Request | "name": ["This field must be unique."] |
| "{%attribute%}" is not int | 400 Bad Request | "object_class": ["Incorrect type. Expected pk value, received {type}."] |
| {%object%} with "{%attribute%}" does not exist | 400 Bad Request | "object_class": ["Invalid pk \"{value}\" - {%object%} does not exist."] |
| "{value}" for {%attribute%} is out of choices | 400 Bad Request | "type": ["\"{value}\" is not a valid choice."] |
| Max {%limit%} {%object_name%} per {%parent_object_name%} exceeded | 400 Bad Request | "detail": ["Limit of {%limit%} {%object_name%} for the {%parent_object_name%} has been exceeded."] |
| Insufficient permissions | 403 Forbidden | "detail": "You do not have permission to perform this action." |
GET /{%endpoint%}/
Returns list of {%object_name%}.
Permissions
Requires authentication and {%resource%}.{%perm%} permission.
TODObelow sentence is not relevant to each resource. Please remove if it's redundant.
Response contains only the {%object_name%} for which the caller has {%resource%}.{%perm%} permission for the associated {%parent_object_name%}.
Request
- Headers
Content-Type: application/json
Authorization: JWT access_token- Schema
GET /{%endpoint%}/
Response
| Key | Type | Notes |
|---|---|---|
| limit | int | |
| offset | int | |
| total_count | int | Total number of results visible to the user (based on permissions). |
| filtered_count | int | Number of results visible to the user (based on permissions) with filters applied. |
| next | url | Next page URL (null if there is no next page) |
| previous | url | Previous page URL (null if there is no previous page) |
| results | Array | List of results. Described in the next table. |
Response results array
| Key | Type | Notes |
|---|---|---|
| uuid | uuid | |
| created_at | datetime | |
| created_by | user | |
| modified_at | datetime | |
| modified_by | user | |
| _meta.labels | Object | Object containing labels for attributes. |
| _meta.permissions | Object | Object describing permissions. |
- Successful status
200 OK - Response body schema
{
"limit": <int>,
"offset": <int>,
"filtered_count": <int>,
"total_count": <int>,
"next": <str | null>,
"previous": <str | null>,
"results": [
{
"uuid": <uuid>,
"{%attribute%}": {%type%},
...
"created_at": <datetime>,
"created_by": <user>,
"modified_at": <datetime>,
"modified_by": <user>,
"_meta": {
"labels": {
"{%attribute%}": <string>
},
"permissions": {
"{%perm%}": <bool>,
...
}
}
}
]
}Sorting
| Parameter | Example | Notes |
|---|---|---|
| /{%endpoint%}/?ordering= | Ascending | |
| /{%endpoint%}/?ordering=- | Descending (-) | |
| created_at | /{%endpoint%}/?ordering=created_at | Ascending |
| created_at | /{%endpoint%}/?ordering=-created_at | Descending (-) |
| modified_at | /{%endpoint%}/?ordering=modified_at | Ascending |
| modified_at | /{%endpoint%}/?ordering=-modified_at | Descending (-) |
Filtering
Please check ALX API standards for predicates available per type.
| Parameter | Type |
|---|---|
| uuid | uuid |
| created_at | datetime |
| created_by | user |
| modified_at | datetime |
| modified_by | user |
Errors
| Error | Response code | Message |
|---|---|---|
| Wrong ordering value | 400 Bad Request | "ordering": ["Select a valid choice. {value} is not one of the available choices."] |
GET /{%endpoint%}/uuid/
Returns single {%object_name%} by uuid.
Permissions
Requires authentication and {%resource%}.{%perm%} permission.
Request
- URL parameters
| Key | Type | Notes |
|---|---|---|
| uuid | uuid |
- Headers
Content-Type: application/json
Authorization: JWT access_token- Schema
GET /{%endpoint%}/
uuid/
Response
| Key | Type | Notes |
|---|---|---|
| uuid | uuid | |
| created_at | datetime | |
| created_by | user | |
| modified_at | datetime | |
| modified_by | user | |
| _meta.labels | Object | Object containing labels for attributes. |
| _meta.permissions | Object | Object describing permissions. |
- Successful status
200 OK - Response body schema:
{
"uuid": <uuid>,
"{%attribute%}": {%type%},
"created_at": <datetime>,
"created_by": <user>,
"modified_at": <datetime>,
"modified_by": <user>,
"_meta": {
"labels": {
"{%attribute%}": <string>
},
"permissions": {
"{%perm%}": <bool>,
...
}
}
}Errors
| Error | Response code | Message |
|---|---|---|
| Insufficient permissions | 403 Forbidden | "detail": "You do not have permission to perform this action." |
| {%object_name%} with "uuid" does not exist | 404 Not Found | "detail": "Not found." |
PATCH /{%endpoint%}/uuid/
Updates single {%object_name%}.
Permissions
Requires authentication and {%resource%}.{%perm%} permission.
Request
- URL parameters
| Key | Type | Notes |
|---|---|---|
| uuid | uuid |
- Body parameters
| Key | Type | Notes |
|---|---|---|
- Headers
Content-Type: application/json
Authorization: JWT access_token- Schema
PATCH /{%endpoint%}/
uuid/
{
"{%attribute%}": "{%str_value%}",
"{%attribute%}": {%int_bool_value%}
...
}Response
| Key | Type | Notes |
|---|---|---|
| uuid | uuid | |
| created_at | datetime | |
| created_by | user | |
| modified_at | datetime | |
| modified_by | user | |
| _meta.labels | Object | Object containing labels for attributes. |
| _meta.permissions | Object | Object describing permissions. |
- Successful status
200 OK - Response body schema:
{
"uuid": <uuid>,
"{%attribute%}": {%type%},
"created_at": <datetime>,
"created_by": <user>,
"modified_at": <datetime>,
"modified_by": <user>,
"_meta": {
"labels": {
"{%attribute%}": <string>
},
"permissions": {
"{%perm%}": <bool>,
...
}
}Errors
| Error | Response code | Message |
|---|---|---|
| {%object_name%} with "uuid" does not exist | 400 Bad Request | "detail": "You do not have permission to perform this action." |
| "{%attribute%}" is empty string | 400 Bad Request | "name": ["This field may not be blank."] |
| "{%attribute%}" is null | 400 Bad Request | "name": ["This field may not be null."] |
| "{%attribute%}" has > {%limit%} chars | 400 Bad Request | "name": ["Ensure this field has no more than {%limit%} characters."] |
| "{%attribute%}" is not unique | 400 Bad Request | "name": ["This field must be unique."] |
| Insufficient permissions | 403 Forbidden | "detail": "You do not have permission to perform this action." |
DELETE /{%endpoint%}/uuid/
Deletes single {%object_name%}.
Permissions
Requires authentication and {%resource%}.{%perm%} permission.
Request
- URL parameters
| Key | Type | Notes |
|---|---|---|
| uuid | uuid |
- Headers
Content-Type: application/json
Authorization: JWT access_token- Schema
DELETE /{%endpoint%}/
uuid/
Response
- Successful status
204 No Content
Errors
| Error | Response code | Message |
|---|---|---|
| Insufficient permissions | 403 Forbidden | "detail": "You do not have permission to perform this action." |
| {%object_name%} with "uuid" does not exist | 404 Not Found | "detail": "Not found." |
OPTIONS /{%endpoint%}/
Permissions
Requires authentication only.
Request
- Headers
Content-Type: application/json
Authorization: JWT access_token- Schema
OPTIONS /{%endpoint%}/
Response
- Successful status
200 OK - Response body:
{
"list": {
"columns": [
{
"alias": "uuid",
"type": "uuid",
"predicates": [
"exact"
],
"sort_ok": false
},
{
"alias": "{%attribute%}",
"type": "{%type%}",
"predicates": [
"{%predicate%}",
...
],
"sort_ok": {%bool_value%}
},
...
{
"alias": "created_at",
"type": "datetime",
"predicates": [
"exact",
"gt",
"gte",
"lt",
"lte",
"range"
],
"sort_ok": true
},
{
"alias": "created_by",
"type": "user",
"predicates": [
"exact",
"in"
],
"sort_ok": false,
"autocomplete": "/api/users/autocomplete/?text__icontains="
},
{
"alias": "modified_at",
"type": "datetime",
"predicates": [
"exact",
"gt",
"gte",
"lt",
"lte",
"range"
],
"sort_ok": true
},
{
"alias": "modified_by",
"type": "user",
"predicates": [
"exact",
"in"
],
"sort_ok": false,
"autocomplete": "/api/users/autocomplete/?text__icontains="
}
]
},
"details": {
"schema": [
{
"alias": "{%attribute%}",
"type": "{%type%}",
"required": {%bool_value%},
"validators": [
{
"type": "{%slug_name_for_validator%}",
"length": {%value%}
}
]
},
...
]
},
"restrictions": {
"{%restriction_slug%}": {%value%}
}
}