Notifications API (v1)

https://github.com/folio-org/mod-notify

Table of contents

mod-notify API

This documents the API calls that can be made to post notifications for users, and to get them

Notifications

Notifications from the system to some user

POST /notify

Create a new notify item.

POST /notify
Query Parameters
  • lang: (string - default: en - pattern: [a-zA-Z]{2})

    Requested language. Optional. [lang=en]

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "description": "A notification to a user",
  "additionalProperties": false,
  "properties": {
    "id": {
      "description": "The UUID of this notification",
      "type": "string"
    },
    "recipientId": {
      "description": "The UUID of the receiving user",
      "type": "string"
    },
    "senderId": {
      "description": "The UUID of the sender",
      "type": "string"
    },
    "text": {
      "description": "The text of this notification",
      "type": "string"
    },
    "link": {
      "description": "Link to the relevant item for this notification",
      "type": "string"
    },
    "eventConfigName": {
      "description": "Unique event config name",
      "type": "string"
    },
    "lang": {
      "description": "Notification language",
      "type": "string"
    },
    "context": {
      "type": "object",
      "description": "Context object"
    },
    "seen": {
      "description": "Whether the user has seen this notification",
      "type": "boolean",
      "default": false
    },
    "metadata": {
      "type": "object",
      "$ref": "raml-util/schemas/metadata.schema"
    }
  },
  "required": [
    "text"
  ]
}

Example:

{
  "id": "12345",
  "recipientId": "77777777-7777-7777-7777-777777777777",
  "text": "The book is now available for you",
  "link": "items/23456"
}

Response 201

Returns a newly created item, with server-controlled fields like 'id' populated

Headers
  • Location: required (string)

    URI to the created notify item

Body

Media type: application/json

Type: any

Example:

{
  "id": "12345",
  "recipientId": "77777777-7777-7777-7777-777777777777",
  "text": "The book is now available for you",
  "link": "items/23456"
}

Response 400

Bad request, e.g. malformed request body or query parameter. Details of the error (e.g. name of the parameter or line/character number with malformed data) provided in the response.

Body

Media type: text/plain

Type: any

Example:

"unable to add notify -- malformed JSON at 13:3"

Response 401

Not authorized to perform requested action

Body

Media type: text/plain

Type: any

Example:

unable to create notify -- unauthorized

Response 422

Validation errors

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "errors": {
      "id": "errors",
      "type": "array",
      "items": {
        "type": "object",
        "$ref": "error.schema"
      }
    },
    "total_records": {
      "type": "integer"
    }
  }
}

Example:

{
  "errors": [
    {
      "message": "may not be null",
      "type": "1",
      "code": "-1",
      "parameters": [
        {
          "key": "moduleTo",
          "value": "null"
        }
      ]
    }
  ]
}

Response 500

Internal server error, e.g. due to misconfiguration

Body

Media type: text/plain

Type: any

Example:

Internal server error, contact administrator

GET /notify

Retrieve a list of notify items.

GET /notify
Query Parameters
  • query: (string)

    A query expressed as a CQL string (see dev.folio.org/reference/glossary#cql) using valid searchable fields. The first example below shows the general form of a full CQL query, but those fields might not be relevant in this context.

    with valid searchable fields: for example link = 1234

    Example:

    (username=="ab*" or personal.firstName=="ab*" or personal.lastName=="ab*") and active=="true" sortby personal.lastName personal.firstName barcode
    
    link=/users/1234
    
  • offset: (integer - default: 0 - minimum: 0 - maximum: 2147483647)

    Skip over a number of elements by specifying an offset value for the query

    Example:

    0
  • limit: (integer - default: 10 - minimum: 0 - maximum: 2147483647)

    Limit the number of elements returned in the response

    Example:

    10
  • lang: (string - default: en - pattern: [a-zA-Z]{2})

    Requested language. Optional. [lang=en]

Response 200

Returns a list of notify items

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "description": "Collection of notifications",
  "properties": {
    "notifications": {
      "description": "List of notifications",
      "type": "array",
      "items": {
        "type": "object",
        "$ref": "notify.json"
      }
    },
    "totalRecords": {
      "type": "integer"
    }
  },
  "required": [
    "notifications",
    "totalRecords"
  ]
}

Example:

{
  "notifications": [],
  "totalRecords": 0
}

Response 400

Bad request, e.g. malformed request body or query parameter. Details of the error (e.g. name of the parameter or line/character number with malformed data) provided in the response.

Body

Media type: text/plain

Type: any

Example:

unable to list notify -- malformed parameter 'query', syntax error at column 6

Response 401

Not authorized to perform requested action

Body

Media type: text/plain

Type: any

Example:

unable to list notify -- unauthorized

Response 422

Validation errors

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "errors": {
      "id": "errors",
      "type": "array",
      "items": {
        "type": "object",
        "$ref": "error.schema"
      }
    },
    "total_records": {
      "type": "integer"
    }
  }
}

Example:

{
  "errors": [
    {
      "message": "may not be null",
      "type": "1",
      "code": "-1",
      "parameters": [
        {
          "key": "moduleTo",
          "value": "null"
        }
      ]
    }
  ]
}

Response 500

Internal server error, e.g. due to misconfiguration

Body

Media type: text/plain

Type: any

Example:

internal server error, contact administrator

POST /notify/_username/{username}

POST /notify/_username/{username}
URI Parameters
  • username: required (string)
Query Parameters
  • lang: (string - default: en - pattern: [a-zA-Z]{2})

    Requested language. Optional. [lang=en]

Body

Media type: application/json

Response 201

Created

Headers
  • Location: required (string)

    URI to the notification

  • X-Okapi-Trace: required (string)

    Okapi trace and timing

Body

Media type: application/json

Response 400

Bad Request

Body

Media type: text/plain

Type: any

Response 422

Validation errors

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "errors": {
      "id": "errors",
      "type": "array",
      "items": {
        "type": "object",
        "$ref": "error.schema"
      }
    },
    "total_records": {
      "type": "integer"
    }
  }
}

Example:

{
  "errors": [
    {
      "message": "may not be null",
      "type": "1",
      "code": "-1",
      "parameters": [
        {
          "key": "moduleTo",
          "value": "null"
        }
      ]
    }
  ]
}

Response 500

Server Error

Body

Media type: text/plain

Type: any

GET /notify/_self

Retrieve a list of _self items.

GET /notify/_self
Query Parameters
  • query: (string)

    A query expressed as a CQL string (see dev.folio.org/reference/glossary#cql) using valid searchable fields. The first example below shows the general form of a full CQL query, but those fields might not be relevant in this context.

    with valid searchable fields: for example link = 1234

    Example:

    (username=="ab*" or personal.firstName=="ab*" or personal.lastName=="ab*") and active=="true" sortby personal.lastName personal.firstName barcode
    
    link=/users/1234
    
  • offset: (integer - default: 0 - minimum: 0 - maximum: 2147483647)

    Skip over a number of elements by specifying an offset value for the query

    Example:

    0
  • limit: (integer - default: 10 - minimum: 0 - maximum: 2147483647)

    Limit the number of elements returned in the response

    Example:

    10
  • lang: (string - default: en - pattern: [a-zA-Z]{2})

    Requested language. Optional. [lang=en]

Response 200

Returns a list of _self items

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "description": "Collection of notifications",
  "properties": {
    "notifications": {
      "description": "List of notifications",
      "type": "array",
      "items": {
        "type": "object",
        "$ref": "notify.json"
      }
    },
    "totalRecords": {
      "type": "integer"
    }
  },
  "required": [
    "notifications",
    "totalRecords"
  ]
}

Example:

{
  "notifications": [],
  "totalRecords": 0
}

Response 400

Bad request, e.g. malformed request body or query parameter. Details of the error (e.g. name of the parameter or line/character number with malformed data) provided in the response.

Body

Media type: text/plain

Type: any

Example:

unable to list _self -- malformed parameter 'query', syntax error at column 6

Response 401

Not authorized to perform requested action

Body

Media type: text/plain

Type: any

Example:

unable to list _self -- unauthorized

Response 422

Validation errors

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "errors": {
      "id": "errors",
      "type": "array",
      "items": {
        "type": "object",
        "$ref": "error.schema"
      }
    },
    "total_records": {
      "type": "integer"
    }
  }
}

Example:

{
  "errors": [
    {
      "message": "may not be null",
      "type": "1",
      "code": "-1",
      "parameters": [
        {
          "key": "moduleTo",
          "value": "null"
        }
      ]
    }
  ]
}

Response 500

Internal server error, e.g. due to misconfiguration

Body

Media type: text/plain

Type: any

Example:

internal server error, contact administrator

DELETE /notify/_self

DELETE /notify/_self
Query Parameters
  • olderthan: (string)

    Delete all seen notifications not modified since this timestamp

    Example:

    2017-12-25
  • lang: (string - default: en - pattern: [a-zA-Z]{2})

    Requested language. Optional. [lang=en]

Response 204

No Content

Response 400

Bad Request

Body

Media type: text/plain

Type: any

Response 404

Not found

Body

Media type: text/plain

Type: any

Response 422

Validation errors

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "errors": {
      "id": "errors",
      "type": "array",
      "items": {
        "type": "object",
        "$ref": "error.schema"
      }
    },
    "total_records": {
      "type": "integer"
    }
  }
}

Example:

{
  "errors": [
    {
      "message": "may not be null",
      "type": "1",
      "code": "-1",
      "parameters": [
        {
          "key": "moduleTo",
          "value": "null"
        }
      ]
    }
  ]
}

Response 500

Server Error

Body

Media type: text/plain

Type: any

POST /notify/_self

Create a new _self item.

POST /notify/_self
Query Parameters
  • lang: (string - default: en - pattern: [a-zA-Z]{2})

    Requested language. Optional. [lang=en]

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "description": "A notification to a user",
  "additionalProperties": false,
  "properties": {
    "id": {
      "description": "The UUID of this notification",
      "type": "string"
    },
    "recipientId": {
      "description": "The UUID of the receiving user",
      "type": "string"
    },
    "senderId": {
      "description": "The UUID of the sender",
      "type": "string"
    },
    "text": {
      "description": "The text of this notification",
      "type": "string"
    },
    "link": {
      "description": "Link to the relevant item for this notification",
      "type": "string"
    },
    "eventConfigName": {
      "description": "Unique event config name",
      "type": "string"
    },
    "lang": {
      "description": "Notification language",
      "type": "string"
    },
    "context": {
      "type": "object",
      "description": "Context object"
    },
    "seen": {
      "description": "Whether the user has seen this notification",
      "type": "boolean",
      "default": false
    },
    "metadata": {
      "type": "object",
      "$ref": "raml-util/schemas/metadata.schema"
    }
  },
  "required": [
    "text"
  ]
}

Example:

{
  "id": "12345",
  "recipientId": "77777777-7777-7777-7777-777777777777",
  "text": "The book is now available for you",
  "link": "items/23456"
}

Response 201

Returns a newly created item, with server-controlled fields like 'id' populated

Headers
  • Location: required (string)

    URI to the created _self item

Body

Media type: application/json

Type: any

Example:

{
  "id": "12345",
  "recipientId": "77777777-7777-7777-7777-777777777777",
  "text": "The book is now available for you",
  "link": "items/23456"
}

Response 400

Bad request, e.g. malformed request body or query parameter. Details of the error (e.g. name of the parameter or line/character number with malformed data) provided in the response.

Body

Media type: text/plain

Type: any

Example:

"unable to add _self -- malformed JSON at 13:3"

Response 401

Not authorized to perform requested action

Body

Media type: text/plain

Type: any

Example:

unable to create _self -- unauthorized

Response 500

Internal server error, e.g. due to misconfiguration

Body

Media type: text/plain

Type: any

Example:

Internal server error, contact administrator

PUT /notify/{id}

Update notify item with given {notifyId}

PUT /notify/{id}
URI Parameters
  • id: required (string)
Query Parameters
  • lang: (string - default: en - pattern: [a-zA-Z]{2})

    Requested language. Optional. [lang=en]

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "description": "A notification to a user",
  "additionalProperties": false,
  "properties": {
    "id": {
      "description": "The UUID of this notification",
      "type": "string"
    },
    "recipientId": {
      "description": "The UUID of the receiving user",
      "type": "string"
    },
    "senderId": {
      "description": "The UUID of the sender",
      "type": "string"
    },
    "text": {
      "description": "The text of this notification",
      "type": "string"
    },
    "link": {
      "description": "Link to the relevant item for this notification",
      "type": "string"
    },
    "eventConfigName": {
      "description": "Unique event config name",
      "type": "string"
    },
    "lang": {
      "description": "Notification language",
      "type": "string"
    },
    "context": {
      "type": "object",
      "description": "Context object"
    },
    "seen": {
      "description": "Whether the user has seen this notification",
      "type": "boolean",
      "default": false
    },
    "metadata": {
      "type": "object",
      "$ref": "raml-util/schemas/metadata.schema"
    }
  },
  "required": [
    "text"
  ]
}

Example:

{
  "id": "12345",
  "recipientId": "77777777-7777-7777-7777-777777777777",
  "text": "The book is now available for you",
  "link": "items/23456"
}

Response 204

Item successfully updated

Response 400

Bad request, e.g. malformed request body or query parameter. Details of the error (e.g. name of the parameter or line/character number with malformed data) provided in the response.

Body

Media type: text/plain

Type: any

Example:

"unable to update notify -- malformed JSON at 13:4"

Response 404

Item with a given ID not found

Body

Media type: text/plain

Type: any

Example:

"notify not found"

Response 422

Validation errors

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "errors": {
      "id": "errors",
      "type": "array",
      "items": {
        "type": "object",
        "$ref": "error.schema"
      }
    },
    "total_records": {
      "type": "integer"
    }
  }
}

Example:

{
  "errors": [
    {
      "message": "may not be null",
      "type": "1",
      "code": "-1",
      "parameters": [
        {
          "key": "moduleTo",
          "value": "null"
        }
      ]
    }
  ]
}

Response 500

Internal server error, e.g. due to misconfiguration

Body

Media type: text/plain

Type: any

Example:

internal server error, contact administrator

GET /notify/{id}

Retrieve notify item with given {notifyId}

GET /notify/{id}
URI Parameters
  • id: required (string)
Query Parameters
  • lang: (string - default: en - pattern: [a-zA-Z]{2})

    Requested language. Optional. [lang=en]

Response 200

Returns item with a given ID

Body

Media type: application/json

Type: json

Content:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "description": "A notification to a user",
  "additionalProperties": false,
  "properties": {
    "id": {
      "description": "The UUID of this notification",
      "type": "string"
    },
    "recipientId": {
      "description": "The UUID of the receiving user",
      "type": "string"
    },
    "senderId": {
      "description": "The UUID of the sender",
      "type": "string"
    },
    "text": {
      "description": "The text of this notification",
      "type": "string"
    },
    "link": {
      "description": "Link to the relevant item for this notification",
      "type": "string"
    },
    "eventConfigName": {
      "description": "Unique event config name",
      "type": "string"
    },
    "lang": {
      "description": "Notification language",
      "type": "string"
    },
    "context": {
      "type": "object",
      "description": "Context object"
    },
    "seen": {
      "description": "Whether the user has seen this notification",
      "type": "boolean",
      "default": false
    },
    "metadata": {
      "type": "object",
      "$ref": "raml-util/schemas/metadata.schema"
    }
  },
  "required": [
    "text"
  ]
}

Example:

{
  "id": "12345",
  "recipientId": "77777777-7777-7777-7777-777777777777",
  "text": "The book is now available for you",
  "link": "items/23456"
}

Response 404

Item with a given ID not found

Body

Media type: text/plain

Type: any

Example:

"notify not found"

Response 500

Internal server error, e.g. due to misconfiguration

Body

Media type: text/plain

Type: any

Example:

internal server error, contact administrator

DELETE /notify/{id}

Delete notify item with given {notifyId}

DELETE /notify/{id}
URI Parameters
  • id: required (string)
Query Parameters
  • lang: (string - default: en - pattern: [a-zA-Z]{2})

    Requested language. Optional. [lang=en]

Response 204

Item deleted successfully

Response 400

Bad request, e.g. malformed request body or query parameter. Details of the error (e.g. name of the parameter or line/character number with malformed data) provided in the response.

Body

Media type: text/plain

Type: any

Example:

"unable to delete notify -- constraint violation"

Response 404

Item with a given ID not found

Body

Media type: text/plain

Type: any

Example:

"notify not found"

Response 500

Internal server error, e.g. due to misconfiguration

Body

Media type: text/plain

Type: any

Example:

Internal server error, contact administrator