Users

Identifiers

A random ID is generated for each user that is created. To fetch data on a specific user this ID is often required as a parameter of an API call. External systems often have no knowledge of the randomly generated ID so they must first make a separate call to look up the user using data they do know that can identify the user, such as an email address or the ID of a connected OpenID provider.

NeoDay User ID

The NeoDay User ID is a randomly generated alphanumeric ID of 25 characters that will look something like this: cgaemb9pqpzhebcneq6tz9e4j.

Looking up a user using the ID of a connected OpenID provider

If there is an OpenID provider configured you can use the following endpoint to fetch the NeoDay user ID for a specific ID of that provider. The call requires the provider name, in this case acme and the user's ID for that provider:

GET /api/1/oauth2/provider/acme/e0024adc-8327-4cc9-b9e1-4de23fe090b3
Host: gateway.acme.neo.day
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9........
HTTP/2 200 Ok
Content-Type: application/json

{
    "owner_id": "e0024adc-8327-4cc9-b9e1-4de23fe090b3",
    "provider_name": "acme",
    "user_id": "cgaemb9pqpzhebcneq6tz9e4j"
}

Listing all connected accounts of a user

A single user can connect with any of the configured OpenID providers. All connected accounts of a user can be listed with the following API call.

GET /api/1/user/connections/cgaemb9pqpzhebcneq6tz9e4j HTTP/2
Host: gateway.acme.neo.day
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9........
HTTP/2 200 Ok
Content-Type: application/json

[
    {
        "owner_id": "e0024adc-8327-4cc9-b9e1-4de23fe090b3",
        "provider_name": "acme",
        "user_id": "cgaemb9pqpzhebcneq6tz9e4j"
    },
    {
        "owner_id": "03948342543897927342",
        "provider_name": "facebook",
        "user_id": "cgaemb9pqpzhebcneq6tz9e4j"
    },
    {
        "owner_id": "398487923485883009",
        "provider_name": "google",
        "user_id": "cgaemb9pqpzhebcneq6tz9e4j"
    }
]

Creating a new connection

A connection is automatically created when a user logs in using an OpenID provider. In the case you want to create a connection in advance you can make a POST to /api/1/oauth2/provider/acme/{owner_id}.

POST /api/1/oauth2/provider/acme/ecbae586-1be9-4be2-9434-52a4ec2f297d
Host: gateway.acme.neo.day
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9........
HTTP/2 200 Ok
Content-Type: application/json

{
    "owner_id": "ecbae586-1be9-4be2-9434-52a4ec2f297d",
    "provider_name": "acme",
    "user_id": "mhmshxv6qajmhjy1k9zd8rnvm"
}

This will create the user if it does not exist yet. No error is returned if the user is already known.

Adding a connection to an existing user

You can add connections for a provider to an existing user like so:

POST /api/1/user/connections/cgaemb9pqpzhebcneq6tz9e4j HTTP/2
Host: gateway.acme.neo.day
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9........

{
    "provider_name": "acme",
    "owner_id": "ecbae586-1be9-4be2-9434-52a4ec2f297d"
}
HTTP/2 200 Ok
Content-Type: application/json

{
    "owner_id": "ecbae586-1be9-4be2-9434-52a4ec2f297d",
    "provider_name": "acme",
    "user_id": "cgaemb9pqpzhebcneq6tz9e4j"
}

The "owner_id" can only be connected to a single user. If the connection already exists an error will be returned.

Retrieving user details

GET /api/1/user/details/cgaemb9pqpzhebcneq6tz9e4j HTTP/2
Host: gateway.acme.neo.day
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9........
HTTP/2 200 Ok
Content-Type: application/json

{
    "id": "cgaemb9pqpzhebcneq6tz9e4j",
    "active": true,
    "completed_registration": true
}

Looking up a user by their username

The specified username must match exactly in order to find the user.

POST /api/1/user/credentials/find HTTP/2
Host: gateway.acme.neo.day
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9........

{
    "username": "[email protected]"
}
HTTP/2 200 Ok
Content-Type: application/json

{
    "user_id": "cgaemb9pqpzhebcneq6tz9e4j",
    "username": "[email protected]"
}

If the user cannot be found a 404 is returned.

Deleting a user

POST /api/1/user/cgaemb9pqpzhebcneq6tz9e4j/delete
Host: gateway.acme.neo.day
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9........
HTTP/1.1 200 Ok 
Content-Type: application/json

{
    "deleted": true
}