Skip to content

Object Record Owners

This technical design describes API for Object Record Owners.

Implementation details can be found in external document: Event History - Object Records - Technical Design.

Object Records Owners API

POST /api/object-records/record_id/owners/

Creates Object Record Owner relations.

Permissions

Requires authentication and any of

  1. object_records.edit permission
  2. Object Record Ownership

URL parameters

KeyNotes
record_idObject Record ID

Request example

  • Headers
Request Method: POST
Content-Type: application/json
Authorization: JWT access_token

Body

KeyTypeRequiredNotes
-listTrueowner ids list

Validations

  • Maximum number of Owners per specific Object Record: 1.
  • Maximum number of Owners in batch: 1.
  • User is validated by account type, one_time_completion account cannot be owner.

Sample request body

POST /api/object-records/1/owners/

json

[
   2
]

Response

KeyTypeNotes
idintAutomatically generated by the backend.
namestring
owner_idint
typestring
created_atdatetime
created_byuser
userObject
  • Response user Object
KeyTypeNotes
idintAutomatically generated by the backend.
usernamestring
first_namestring
last_namestring
account_typestring
company_namestring
is_deletedbool
  • Successful status 201 Created
  • Response body schema
json
{
   "id": 10,
   "owner_id": 41,
   "type": "user",
   "name": "sample name",
   "created_at": "2023-07-10T09:28:27.679165+02:00",
   "created_by": "some name (test.autologyx@autologyx.com)",
   "user": {
      "id":41,
      "first_name": "first name",
      "last_name": "last name",
      "username": "test.autologyx@autologyx.com",
      "company_name": "autologyx",
      "is_deleted": false,
      "account_type": "full"
   }
}

Errors

CauseResponse codeMessage
record_id is invalid400 Bad Request"detail": "Invalid pk "99999" - object does not exist."
record_id is not int400 Bad Request"detail": "Incorrect type. Expected pk value, received str."
list in body is empty400 Bad Request"detail": "This list may not be empty."
body has incorrect type400 Bad Request"detail": "Expected a list of items but got type "str"."
owner has wrong type400 Bad Request"detail": "1 Time Completion account cannot be owner."
batch size is above the limit400 Bad Request"detail": "Up to 1 item allowed."
object record owners is above the limit400 Bad Request"detail": "Limit of 1 Object Record Owners has been exceeded."
Request user does not have "users.list" permission for the user to be assigned as the Object Record owner400 Bad Request"detail": ["You do not have permission to make user "{user_id}" the owner of Object Record "{record_id}"."]
insufficient permissions403 Forbidden"detail": "You do not have permission to perform this action."

GET /api/object-records/record_id/owners/

Returns list of owners.

Permissions

Requires authentication and any of

  1. object_records.view permission
  2. Object Record Ownership

URL parameters

KeyNotes
record_idObject Record ID

Request example

  • Headers
Request Method: GET
Content-Type: application/json
Authorization: JWT access_token

Response

KeyTypeNotes
limitint
offsetint
total_countintTotal number of results visible to the user (based on permissions).
filtered_countintNumber of results visible to the user (based on permissions) with filters applied.
nexturlNext page URL (null if there is no next page)
previousurlPrevious page URL (null if there is no previous page)
resultsArrayList of results. Described in the next table.

Response results array

KeyTypeNotes
idintAutomatically generated by the backend.
namestring
owner_idint
typestring
created_atdatetime
created_byuser
userObject
  • Successful status 200 OK
  • Response body schema
json
{
  "limit":50,
  "offset":0,
  "filtered_count":1,
  "total_count":1,
  "next":null,
  "previous":null,
  "results":[
    {
      "id":22,
      "owner_id":641,
      "type":"user",
      "name":"sample name",
      "created_at":"2023-07-10T09:28:27.679165+02:00",
      "created_by":"some name (test.autologyx@autologyx.com)",
      "user":
        {
          "id":641,
          "first_name":"sample first name",
          "last_name":"sample last name",
          "username":"test.autologyx@example.test",
          "company_name":"autologyx",
          "is_deleted":false,
          "account_type":"full"
        }
    }]}

Sorting

ParameterExampleNotes
id{build}/api/object-records/record_id/owners/?ordering=idAscending
id{build}/api/object-records/record_id/owners/?ordering=-idDescending (-)
name{build}/api/object-records/record_id/owners/?ordering=nameAscending
name{build}/api/object-records/record_id/owners/?ordering=-nameDescending (-)
created_at{build}/api/object-records/record_id/owners/?ordering=created_atAscending
created_at{build}/api/object-records/record_id/owners/?ordering=-created_atDescending (-)

Filtering

ParameterTypeExample
idint{build}/api/object-records/record_id/owners/?id=1
owner_iddatetime{build}/api/object-records/record_id/owners/?owner_id=2
namestring{build}/api/object-records/record_id/owners/?name=John
created_atdatetime{build}/api/object-records/record_id/owners/?created_at__gte=2022-01-01
created_byenum{build}/api/object-records/record_id/owners/?created_by=321

Errors

CauseResponse codeMessage
Insufficient permissions403 Forbidden"detail": "You do not have permission to perform this action."

GET /api/object-records/record_id/owners/owner_id/

Response example

  • Status 405 Method Not Allowed

DELETE /api/object-records/record_id/owners/object_record_owner_id/

Delete single object relation record.

Permissions

Requires authentication and any of

  1. object_records.edit permission
  2. Object Record Ownership

URL parameters

KeyNotes
record_idObject Record ID
object_record_owner_idObject Record Owner ID

Request example

  • Headers
Request Method: DELETE
Content-Type: application/json
Authorization: JWT access_token

Response

  • Successful status 204 No Content

Errors

CauseResponse codeMessage
Insufficient permissions403 Forbidden"detail": "You do not have permission to perform this action."

OPTIONS /api/object-records/record_id/owners/

Permissions

Requires authentication only.

Request example

  • Headers
Request Method: DELETE
Content-Type: application/json
Authorization: JWT access_token

Response example

  • Status 200 OK
  • Body
json
{
    "list": {
        "columns": [
            {
                "alias": "id",
                "type": "int",
                "predicates": [
                    "exact",
                    "gt",
                    "gte",
                    "lt",
                    "lte",
                    "range"
                ],
                "sort_ok": true
            },
            {
                "alias": "owner_id",
                "type": "int",
                "predicates": [
                    "exact",
                    "gt",
                    "gte",
                    "lt",
                    "lte",
                    "range"
                ],
                "sort_ok": false
            },
            {
                "alias": "name",
                "type": "string",
                "predicates": [
                    "exact",
                    "iexact",
                    "contains",
                    "icontains",
                    "startswith",
                    "istartswith",
                    "endswith",
                    "iendswith"
                ],
                "sort_ok": true
            },
            {
                "alias": "created_at",
                "type": "datetime",
                "predicates": [
                    "exact",
                    "gt",
                    "gte",
                    "lt",
                    "lte",
                    "range"
                ],
                "sort_ok": true
            },
            {
                "alias": "created_by",
                "type": "enum",
                "predicates": [
                    "exact",
                    "in"
                ],
                "sort_ok": false,
                "autocomplete": "/api/users/autocomplete/?text__icontains="
            }
        ]
    },
    "batch": {
        "type": "set",
        "required": true,
        "autocomplete": "/api/users/autocomplete/?account_type!=one_time_completion&text__icontains="
    },
    "restrictions": {
        "limit_items": 1,
        "limit_items_in_batch": 1
    }
}