Users

The Users resource is used to create and list users.

Listing users

A GET request will list all of the service’s users.

Response structure
Path Type Description

_embedded.chatty:users

Array

An array of User resources

_links

Object

Links to other resources

page

Object

The pagination information

Example request
$ curl 'http://localhost:8080/api/users' -i -X GET
Example response
HTTP/1.1 200 OK
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Content-Type: application/hal+json
Content-Length: 1477

{
  "_embedded" : {
    "chatty:users" : [ {
      "id" : "user_1",
      "fullName" : "Kai Toedter",
      "email" : "kai@toedter.com",
      "_links" : {
        "self" : {
          "href" : "http://localhost:8080/api/users/user_1"
        },
        "chatty:user" : {
          "href" : "http://localhost:8080/api/users/user_1{?projection}",
          "templated" : true
        },
        "chatty:messages" : {
          "href" : "http://localhost:8080/api/users/user_1/messages{?projection}",
          "templated" : true
        }
      }
    }, {
      "id" : "user_2",
      "fullName" : "John Doe",
      "email" : "john@doe.com",
      "_links" : {
        "self" : {
          "href" : "http://localhost:8080/api/users/user_2"
        },
        "chatty:user" : {
          "href" : "http://localhost:8080/api/users/user_2{?projection}",
          "templated" : true
        },
        "chatty:messages" : {
          "href" : "http://localhost:8080/api/users/user_2/messages{?projection}",
          "templated" : true
        }
      }
    } ]
  },
  "_links" : {
    "self" : {
      "href" : "http://localhost:8080/api/users"
    },
    "profile" : {
      "href" : "http://localhost:8080/api/profile/users"
    },
    "curies" : [ {
      "href" : "http://localhost:8080/../docs/html5/{rel}.html",
      "name" : "chatty",
      "templated" : true
    } ]
  },
  "page" : {
    "size" : 20,
    "totalElements" : 2,
    "totalPages" : 1,
    "number" : 0
  }
}
Relation Description

self

The Users resource

profile

The profile describes the data structure of this resource

curies

Curies are used for online documentation

Creating a user

A POST request is used to create a user

Request structure
Path Type Description

id

String

The id of the user. Must be unique.

fullName

String

The full name of the user

email

String

The e-mail of the user

Example request
$ curl 'http://localhost:8080/api/users' -i -X POST \
    -H 'Content-Type: application/hal+json' \
    -d '{
  "fullName" : "toedter_k",
  "id" : "toedter_k",
  "email" : "kai@toedter.com"
}'
Example response
HTTP/1.1 201 Created
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Location: http://localhost:8080/api/users/toedter_k

User

The User resource is used to get and change a single user.

Getting a user

Response structure
Path Type Description

id

String

The id of the user. Must be unique.

fullName

String

The full name of the user

email

String

The e-mail of the user

_links

Object

Links to other resources

Example request
$ curl 'http://localhost:8080/api/users/user_1' -i -X GET
Example response
HTTP/1.1 200 OK
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Content-Type: application/hal+json
Content-Length: 577

{
  "id" : "user_1",
  "fullName" : "John Doe",
  "email" : "john@doe.com",
  "_links" : {
    "self" : {
      "href" : "http://localhost:8080/api/users/user_1"
    },
    "chatty:user" : {
      "href" : "http://localhost:8080/api/users/user_1{?projection}",
      "templated" : true
    },
    "chatty:messages" : {
      "href" : "http://localhost:8080/api/users/user_1/messages{?projection}",
      "templated" : true
    },
    "curies" : [ {
      "href" : "http://localhost:8080/../docs/html5/{rel}.html",
      "name" : "chatty",
      "templated" : true
    } ]
  }
}
Relation Description

self

the self link to this user

chatty:user

the (possibly templated) link to this user

chatty:messages

The Messages of this user

curies

Curies are used for online documentation