Core - License Documents

The base url for the APIs in this page is at:

/api/admin

A JSON file with OpenAPI data about all core-related admin APIs can be downloaded here.

Get a license document of end user

Gets details of a specific license document by user:

GET /v1/end-users/{id}/license-documents/{lid}

Gets details about a specific license document

Parameters
  • lid (integer) – The id of the document

  • id (string) –

Status Codes
id: User ID (Int)
lid: The id of the document (Int)

Returns a Json positive response and the details of the specific license document:

{
  ID: 1234,                                       // Int
  UserID: 1234,                                   // Int
  UserName: "UserName",                           // String
  Type: 0,                                        // Int
  LicenseNumber: "SMITH1763211112U",              // String
  IssuingAuthorityID: 1234,                       // Int
  IssuingAuthority: "Authority Name",             // String
  Category: "B",                                  // String
  EquivalentCategory: "B",                        // String (nullable)
  CreatedDate: "2001-01-01T01:01:01Z",            // DateTime
  LastValidationDate: "2001-01-01T01:01:01Z",     // DateTime (nullable)
  IssueDate: "2001-01-01T01:01:01Z",              // DateTime
  ExpiryDate: "2001-01-01T01:01:01Z",             // DateTime (nullable)
  IsExpired: true,                                // Boolean
  IsValid: true,                                  // Boolean (nullable)
  IsDeletable: true,                              // Boolean
  Attachments: [ Guid array ],                    // Guid Array
  Notes: "Additional notes",                      // String (nullable)
  Guid: "53155c4a-b2a0-412f-ab41-552d9ccdf784"    // Guid
}

Value of the Type property can be one of the LicenseDocumentType enumeration.

Get latest document of end user

Gets details about the latest license document for the specified user:

GET /v1/end-users/{id}/license-documents/last

Gets details about the latest license document for the specified user

Parameters
  • id (integer) – The id of the user

Status Codes
id: User ID (Int)

Returns a Json positive response with the details of the most recent license document of the end user:

{
  "ID": 40,                                              // Int
  "UserID": 5,                                           // Int
  "UserName": "user@test.com",                           // String
  "Type": 0,                                             // Int
  "LicenseNumber": "aaabbb123",                          // String
  "IssuingAuthorityID": 20,                              // Int
  "IssuingAuthority": "MTCT",                            // String
  "Category": "b",                                       // String
  "EquivalentCategory": "b",                             // String
  "CreatedDate": "2019-12-18T13:12:00Z",                 // DateTime
  "IssueDate": "2019-12-01T13:11:09Z",                   // DateTime
  "ExpiryDate": "2020-05-01T12:11:11Z",                  // DateTime (nullable)
  "IsExpired": true,                                     // Boolean
  "LastValidationDate": null,                            // DateTime (nullable)
  "IsValid": true,                                       // Boolean (nullable)
  "IsDeletable": false,                                  // Boolean
  "Attachments": [
    {
      "Guid": "dad015d7-3eb1-4068-88ee-2f9898b86add",    // Guid
      "FileName": "file name"                            // String
    },
    { ... }
  ],
  "Notes": "",                                           // String (nullable)
  "Guid": "dad015d7-3eb1-4068-88ee-2f9898b86add"         // Guid
}

Value of the Type property can be one of the LicenseDocumentType enumeration.

Get license documents of end user

Gets the list of license documents for the specified user (it’s a Paged List APIs, as explained in the introduction), save for the newest one:

GET /v1/end-users/{id}/license-documents/list

Gets the list of license documents for the specified user, save for the last one

Parameters
  • id (integer) – The id of the user

Status Codes
id: User ID (Int)

Returns the list of all the documents of the specified end user:

[
  {
    ID: 1234,                                       // Int
    UserID: 1234,                                   // Int
    UserName: "UserName",                           // String
    Type: 0,                                        // Int
    LicenseNumber: "SMITH1763211112U",              // String
    IssuingAuthorityID: 1234,                       // Int
    IssuingAuthority: "Authority Name",             // String
    Category: "B",                                  // String
    EquivalentCategory: "B",                        // String (nullable)
    CreatedDate: "2001-01-01T01:01:01Z",            // DateTime
    LastValidationDate: "2001-01-01T01:01:01Z",     // DateTime (nullable)
    IssueDate: "2001-01-01T01:01:01Z",              // DateTime
    ExpiryDate: "2001-01-01T01:01:01Z",             // DateTime (nullable)
    IsExpired: true,                                // Boolean
    IsValid: true,                                  // Boolean (nullable)
    IsDeletable: true,                              // Boolean
    Attachments: [ Guid array ],                    // Guid Array
    Notes: "Additional notes",                      // String (nullable)
    Guid: "53155c4a-b2a0-412f-ab41-552d9ccdf784"    // Guid
  },
  ...
]

Value of the Type property can be one of the LicenseDocumentType enumeration.

Add new or edit existing license document for end user

Persists edits about a new or existing license document for a specified user:

POST /v1/end-users/{id}/license-documents

Persists edits about a new or existing license document for a specified user

Parameters
  • id (integer) – The id of the user

Status Codes
id: User ID (Int)

The request body is the following:

{
  LicenseNumber: "SMITH1763211112U",                     // String
  Category: "B",                                         // String
  EquivalentCategory: "B",                               // String (nullable)
  Notes: "Additional notes",                             // String (nullable)
  Type: 0,                                               // Int
  IsValid: true,                                         // Boolean
  IssueDate: "2001-01-01T01:01:01Z",                     // DateTime
  ExpiryDate: "2001-01-01T01:01:01Z",                    // DateTime
  IssuingAuthority: 1234,                                // Int
  IsNewDocument: true,                                   // Bool
  Attachments: ['UPe3czoATcFp5yElsjPrmw==...',...]       // String Array (nullable)
}

If no license document is present for the specified user, the request will create a new one. If the user already has one or more license documents, the request will check the last created document for the user: if the document was created within a time frame (specified in the configuration variable LICENSE_DOCUMENT_EDIT_GRACE_PERIOD_HOURS) the request will update the document, otherwise it will create a new one.

The IsNewDocument property represents, as the name implies, the fact that the front-end operator is editing an old document or adding a new one. This data will be used in the process described above to copy some information about the old document in the new one (i.e. reference to the attached photos) , or to bypass the edit grace time while adding a new document.

Type values can be une of the LicenseDocumentType enumeration.

The Attachments array is considered only while creating a new document, and contains an array of images in base64 string format. The strings represents the license document photos.

Returns a plain Json positive response if the record was successfully added or edited, or a plaing negative one if not.

Possible error messages are:

err_InvalidElement

The id of the user provided does not correspond to any existing end user, or no license number, category or issue date has been provided

err_InvalidDates

The Issue date is greater than the Expiry date or in the future

err_MissingAuthorithy

The specified issuing authority does not exist

Delete license document of end user

Deletes a license document record of the specified end user from the database:

DELETE /v1/end-users/{id}/license-documents/{l_id}

Marks a license document as deleted

Parameters
  • l_id (integer) – The id of the document

  • id (string) –

Status Codes

Returns a plain Json positive reponse if the record is successfully deleted, a negative one if not or a Unauthorized message if you cannot. The document can only be deleted within the allowed time frame, as specified in the configuration variable LICENSE_DOCUMENT_EDIT_GRACE_PERIOD_HOURS.