Auth

Users must authenticate successfully before any further API calls can be made.

To demonstrate, here is an example of how to authenticate to obtain a token and use that token to retrieve port details.

{email:'...',password:'...'}
$token
portal-token: $token
OK
API User
PUT /api/auth/token
PUT /company/exampleCo/ports

Make the following PUT request to authenticate a with a username and password.

curl -X PUT 'https://api.consoleconnect.com/api/auth/token' \
-H 'Content-Type: application/json' \
--data-raw '{
  "email": "user@example.com",
  "password": "Password1"
}'

The response body will include user details, including a “token” element, which must be passed as the value for a “portal-token” header in each subsequent API request.

{
  "..."
  "token": "123456789012345678901234567890123456789012345678901234567890abcd",
  "..."
}

Include the token in the "portal-token" header to make an authenticated request to api/company/exampleCo/ports, which will respond with a list of ports for the company "exampleCo".

curl -X GET https://api.test.consoleconnect.com/api/company/exampleCo/ports \
-H "portal-token: 123456789012345678901234567890123456789012345678901234567890abcd"

Log in

User authentication (login) must occur before any further API calls can be made. The token from the response must be passed as the value for a “portal-token” header in each subsequent API request.

Request
Request Body schema: application/json
email
required
string
password
required
string
Responses
200

OK

401

Unauthorized

put/api/auth/token
Request samples
application/json
{
  • "email": "user@example.com",
  • "password": "Password1"
}
Response samples
application/json
{
  • "token": "e4e0c6e2c5e73963e60a1132948e1c7f84f1f4cdd04a254e9215ab314b48e26e",
  • "id": "58980a25a77b4d7bf459d100",
  • "username": "stella",
  • "name": "Stella",
  • "email": "stella@example.com"
}

Log out

Log the authenticated user out.

Request
header Parameters
portal-token
required
string

User session token obtained by logging in.

Example: 113407e6281579d4f7f4a664db00b15b92de7cd3ccf02b47aa6cfc187d27ca05;
Responses
200

OK

delete/api/auth/token
Response samples
application/json
{ }

Get current user

Retrieve account details for the authenticated user.

Request
header Parameters
portal-token
required
string

User session token obtained by logging in.

Example: 113407e6281579d4f7f4a664db00b15b92de7cd3ccf02b47aa6cfc187d27ca05;
Responses
200

OK

401

Unauthorized

get/api/auth/token
Response samples
application/json
{
  • "id": "58980a25a77b4d7bf459d100",
  • "username": "stella",
  • "name": "Stella",
  • "email": "stella@example.com"
}