8 January, 2022

REST API Notes

Create Entry

This endpoint can be called by clients with Amdin role to create a new entry.

URL: /api/clients

Method: POST

Auth required : YES

Body example:

{
  "client_id": "123456",
  "application_type": "public",
  "display_name": "Wisecards Android",
  "grant_types" : [ "password", "refresh_token" ]
}

Response:

CodeCondition
201When the entry was accepted and created.
400When the entry contains invalid values, see response body to get detailed messages.
401When no valid token was provided.
409When the entry contains values that are not allowed in domain logic.
500When an unexpected technical problem happened and the request cannot be processed.

Success Response

Condition: When the entry was accepted and created.

Code: 201 Created

Header:

Location: https://wisecards.tea.ch/api/clients/123456

Body:

{
  "client_id": "123456"
}

Error Responses

Condition: When the entry contains invalid values, see response body to get detailed messages.

Code: 400 Bad Request

Body:

{
  "errors": [
    {
      "status": "400",
      "detail": "client_id is not valid"
    },
    {
      "status": "400",
      "detail": "client_secret is not valid"
    }
  ]
}

Update Entry

This endpoint can be called by clients with Admin role.

URL: /api/clients/123456

Method: PATCH

Auth required : YES

Body example:

{
  "display_name": "Public Wisecards Client"
}

Response Summary

CodeCondition
204When the entry was successfully updated.
400When the entry contains invalid values, see response body to get detailed messages.
401When no valid token was provided.
404When the entry contains values that are not allowed in domain logic.
500When an unexpected technical problem happened and the request cannot be processed.

Success Response

Condition: When the entry was successfully updated.

Code: 204 No Content

Error Responses

Condition: When the entry contains invalid values, see response body to get detailed messages.

Code: 400 Bad Request

Body:

{
  "errors": [
    {
      "status": "400",
      "detail": "display_name is not valid"
    }
  ]
}

Delete Entry

When status code 202 is returned, the entry can be undeleted. To undelete it see Undelete Entry.

URL: /api/clients/123456

Method: DELETE

Auth required : YES

Response Summary

CodeCondition
200When the entry was successfully deleted.
202When the entry was queued to be deleted.
204When the entry was successfully deleted. No content is returned.
401When no valid token was provided.
404When the entry contains values that are not allowed in domain logic.
500When an unexpected technical problem happened and the request cannot be processed.

Undelete Entry

This is the same endpoint as the update. Updates with is_deleted other than false to an deleted will be rejected with status code 404.

URL: /api/clients/123456

Method: PATCH

Auth required : YES

Body example:

{
  "is_deleted": false
}

Response Summary

CodeCondition
204When the entry was successfully undeleted.
400When the entry contains invalid values, see response body to get detailed messages.
401When no valid token was provided.
404When the entry contains values that are not allowed in domain logic.
500When an unexpected technical problem happened and the request cannot be processed.