GET /api/v2/messages
List the account's own messages

Examples

GET /api/v2/messages
200
{
  "data": [
    {
      "id": "1",
      "type": "messages",
      "links": {
        "self": "http://test.host/api/v2/messages/1"
      },
      "attributes": {
        "content": "Test message.",
        "created-at": "2017-08-29T10:48:03.995+08:00",
        "is-read": true,
        "is-system-message": false
      },
      "relationships": {
        "attachment": {
          "links": {
            "self": "http://test.host/api/v2/messages/1/relationships/attachment",
            "related": "http://test.host/api/v2/messages/1/attachment"
          }
        },
        "message-group": {
          "links": {
            "self": "http://test.host/api/v2/messages/1/relationships/message-group",
            "related": "http://test.host/api/v2/messages/1/message-group"
          }
        },
        "sender": {
          "links": {
            "self": "http://test.host/api/v2/messages/1/relationships/sender",
            "related": "http://test.host/api/v2/messages/1/sender"
          }
        }
      }
    },
    {
      "id": "2",
      "type": "messages",
      "links": {
        "self": "http://test.host/api/v2/messages/2"
      },
      "attributes": {
        "content": "Test message.",
        "created-at": "2017-08-29T10:48:04.157+08:00",
        "is-read": false,
        "is-system-message": false
      },
      "relationships": {
        "attachment": {
          "links": {
            "self": "http://test.host/api/v2/messages/2/relationships/attachment",
            "related": "http://test.host/api/v2/messages/2/attachment"
          }
        },
        "message-group": {
          "links": {
            "self": "http://test.host/api/v2/messages/2/relationships/message-group",
            "related": "http://test.host/api/v2/messages/2/message-group"
          }
        },
        "sender": {
          "links": {
            "self": "http://test.host/api/v2/messages/2/relationships/sender",
            "related": "http://test.host/api/v2/messages/2/sender"
          }
        }
      }
    }
  ],
  "meta": {
    "total-pages": 1,
    "record-count": 2
  },
  "links": {
    "first": "http://test.host/api/v2/messages?page%5Bnumber%5D=1&page%5Bsize%5D=10",
    "last": "http://test.host/api/v2/messages?page%5Bnumber%5D=1&page%5Bsize%5D=10"
  }
}

GET /api/v2/messages/:id
Show a message

Examples

GET /api/v2/messages/48
200
{
  "data": {
    "id": "48",
    "type": "messages",
    "links": {
      "self": "http://test.host/api/v2/messages/48"
    },
    "attributes": {
      "content": "Test message.",
      "created-at": "2017-08-29T10:48:27.649+08:00",
      "is-read": true,
      "is-system-message": false
    },
    "relationships": {
      "attachment": {
        "links": {
          "self": "http://test.host/api/v2/messages/48/relationships/attachment",
          "related": "http://test.host/api/v2/messages/48/attachment"
        }
      },
      "message-group": {
        "links": {
          "self": "http://test.host/api/v2/messages/48/relationships/message-group",
          "related": "http://test.host/api/v2/messages/48/message-group"
        }
      },
      "sender": {
        "links": {
          "self": "http://test.host/api/v2/messages/48/relationships/sender",
          "related": "http://test.host/api/v2/messages/48/sender"
        }
      }
    }
  }
}

Params

Param name Description
id
required

Message ID

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hyphen(-) with no leading or trailing space.


POST /api/v2/messages
Create a message

Params

Param name Description
data
required

Message Information

Validations:

  • Must be a Hash

data[type]
required

Validations:

data[attributes]
required

Validations:

  • Must be a Hash

data[attributes][content]
required

Message content to send

Validations:

  • Must be a String

data[relationships]
required

Validations:

  • Must be a Hash

data[relationships][message-group]
required

Validations:

  • Must be a Hash

data[relationships][message-group][data]
required

Validations:

  • Must be a Hash

data[relationships][message-group][data][type]
required

MessageGroup type, which is `message-groups`

Validations:

  • Must be a String

data[relationships][message-group][data][id]
required

Message group ID

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hyphen(-) with no leading or trailing space.


PATCH /api/v2/messages/:id
Update a message's is-read status

Examples

PATCH /api/v2/messages/56
{
  "data": {
    "id": "56",
    "type": "messages",
    "attributes": {
      "content": "Test message.",
      "created-at": "2017-08-29 10:48:31 +0800",
      "is-read": true,
      "is-system-message": false
    },
    "relationships": {
      "sender": {
        "data": {
          "type": "senders",
          "id": "662"
        }
      }
    }
  }
}
200
{
  "data": {
    "id": "56",
    "type": "messages",
    "links": {
      "self": "/api/v2/messages/56"
    },
    "attributes": {
      "content": "Test message.",
      "created-at": "2017-08-29T10:48:31.682+08:00",
      "is-read": true,
      "is-system-message": false
    },
    "relationships": {
      "attachment": {
        "links": {
          "self": "/api/v2/messages/56/relationships/attachment",
          "related": "/api/v2/messages/56/attachment"
        }
      },
      "message-group": {
        "links": {
          "self": "/api/v2/messages/56/relationships/message-group",
          "related": "/api/v2/messages/56/message-group"
        }
      },
      "sender": {
        "links": {
          "self": "/api/v2/messages/56/relationships/sender",
          "related": "/api/v2/messages/56/sender"
        }
      }
    }
  }
}

Params

Param name Description
id
required

Message ID

Validations:

  • Must be an identifier, string from 1 to 128 characters containing only alphanumeric characters, space, underscore(_), hyphen(-) with no leading or trailing space.

attributes
optional

Validations:

  • Must be a Hash

attributes[is-read]
optional

Update the is-read status

Validations:

  • Must be one of: true, false.