Back to top

Volt API

© 2017 NS BASIC Corporation. All rights reserved.

The Volt API is REST API consisting of a core and plug-ins. The core consists of Authentication and User endpoints. Plug-ins add different functions based on the the core.

The core API also exposes /api/client/volt.min.js which provides a friendly JavaScript interface for clients.

Authenticating

Requests that require authentication require the access_token retrieved from the login endpoint to be included in the HTTP Authorization header. If your access_token is abc123, then your header would look like this: Authorization: Bearer abc123.

If you use the client library, this is handled automatically.

Error responses

Some error responses include additional information in the response body. You can read more about in handling errors.

Authentication

None of these methods require an authentication token.

Register

Register
POST/api/auth/register

Register for an account. Expects JSON containing the requested email (username), password, and confirmation. An optional scope allows this endpoint to be used by app authors to automate registration for their app users. scope is an app ID, but called scope to maintain consistency with the rest of the authentication group which itself is attempting to maintain compatibility with the OAuth2 spec.

This endpoint triggers a confirmation email upon success if a confirmation_url is defined for the scope (app). This can be done via the dashboard.

It is possible to register without a password, by setting both the password and confirmation to null. A password reset will be triggered as opposed to a confirmation.

Example URI

POST /api/auth/register
Request
HideShow
Headers
Content-Type: application/json
Body
{
  "email": "gh@nsbasic.com",
  "password": "insecure",
  "confirmation": "insecure",
  "scope": "Q4VBZVgw"
}
Response  201
HideShow
Headers
Content-Type: application/json
Body
{
  "id": "DA6gHVdJ",
  "email": "gh@nsbasic.com",
  "confirmed": false,
  "admin": false
}
Response  402
HideShow

Returned if the app the scope refers to is not a subscriber app.

Response  404
HideShow

Returned if the app the scope refers to is not found.

Response  406
HideShow

Returned if the request’s Content-Type is not application/json.

Response  409
HideShow

Returned if the email has already been registered under this scope.

Response  422
HideShow

Returned if there’s a problem with the request body (including an undecodeable app ID passed in scope). Also if the password is too weak.

Response  500
HideShow

Returned if there was a server error.

Login

Login
POST/api/auth/login

This endpoint is based on the OAuth2 spec so we can transition if needed. Specifically, this follows Section 4.3 Resource Owner Password Credentials Grant with the exception that requests are made using the JSON rather than form encoding. scope is required and should correspond to an app ID to authenticate against.

Example URI

POST /api/auth/login
Request  With Scope
HideShow
Headers
Content-Type: application/json
Body
{
  "grant_type": "password",
  "username": "gh@nsbasic.com",
  "password": "insecure",
  "scope": "oAyLuW0e"
}
Response  200
HideShow

Returned if the login succeeded. Returns a bearer token per OAuth2 Section 5.1. The access token is a JWT. The user_id is additionally returned so it can be used in future requests (without an additional API call).

Headers
Content-Type: application/json
Body
{
  "access_token": "[Valid JWT]",
  "token_type": "bearer",
  "expires_in": 3600,
  "user_id": "xDe3f5c"
}
Response  401
HideShow

Returned if the login failed.

Response  402
HideShow

Returned if the app the scope refers to is not a subscriber app.

Response  403
HideShow

Returned if the account is unconfirmed and a confirmation_url is defined for the scope (app).

Response  404
HideShow

Returned if the app the scope refers to is not found.

Response  406
HideShow

Returned if the request’s Content-Type is not application/json.

Response  422
HideShow

Returned if there was a problem with the content of the request body or the scope could not be decoded.

Response  500
HideShow

Returned if there was a server error.

Forgot Password

Forgot Password
POST/api/auth/forgot

Posting to this endpoint sends an email to the user with a reset password link. In order to function, the associated app must define said link (via the dashboard). If no link is defined, this endpoint returns an error (501).

Example URI

POST /api/auth/forgot
Request
HideShow
Headers
Content-Type: application/json
Body
{
  "email": "gh@nsbasic.com",
  "scope": "oAyLuW0e"
}
Response  204
HideShow

Returned if there was no problem with the request. This does not confirm or deny account validity.

Response  402
HideShow

Returned if the app the scope refers to is not a subscriber app.

Response  404
HideShow

Returned if the app the scope refers to is not found.

Response  406
HideShow

Returned if the request’s Content-Type is not application/json.

Response  422
HideShow

Returned if there was a problem with the content of the request body or the scope could not be decoded.

Response  500
HideShow

Returned if there was a server error.

Response  501
HideShow

Returned if the reset_url is not defined for the associated app.

Resend Confirmation

Resend Confirmation
POST/api/auth/resend

Posting to this endpoint re-sends a confirmation email to the user if the user is unconfirmed.

Example URI

POST /api/auth/resend
Request
HideShow
Headers
Content-Type: application/json
Body
{
  "email": "gh@nsbasic.com",
  "scope": "oAyLuW0e"
}
Response  204
HideShow

Returned if there was no problem with the request. This does not confirm or deny account existence.

Response  402
HideShow

Returned if the app the scope refers to is not a subscriber app.

Response  404
HideShow

Returned if the app the scope refers to is not found.

Response  406
HideShow

Returned if the request’s Content-Type is not application/json.

Response  422
HideShow

Returned if there was a problem with the content of the request body or the scope could not be decoded.

Response  500
HideShow

Returned if there was a server error.

Response  501
HideShow

Returned if the confirmation_url is not defined for the associated app.

Reset Password

Reset Password
POST/api/auth/reset

Reset a password given a valid confirmation token.

Example URI

POST /api/auth/reset
Request
HideShow
Headers
Content-Type: application/json
Body
{
  "token": "reset token",
  "password": "newpass",
  "confirmation": "newpass"
}
Response  204
HideShow

Returned if the reset was successful

Response  401
HideShow

Returned if the token can’t be authenticated, is expired, or malformed.

Response  406
HideShow

Returned if the request’s Content-Type is not application/json.

Response  422
HideShow

Returned if the password and confirmation do not match, if there is a problem with the request body, or if the password is too weak.

Response  500
HideShow

Returned if there was a server error.

Confirm Account

Confirm Account
POST/api/auth/confirm

Confirms an account given a confirmation token. The token encodes all information about the account being confirmed. The token is passed as part of the confirmation URL. It is up to the application to process the token and call this endpoint. Upon successful the associated user’s account will be marked confirmed.

Example URI

POST /api/auth/confirm
Request
HideShow
Headers
Content-Type: application/json
Body
{
  "token": "confirmation token"
}
Response  204
HideShow

Returned if the confirmation was successful.

Response  401
HideShow

Returned if the token can’t be authenticated, is expired, or malformed.

Response  406
HideShow

Returned if the request’s Content-Type is not application/json.

Response  422
HideShow

Returned if there is a problem with the request body.

Response  500
HideShow

Returned if there was a server error.

Users

These endpoints deal with managing a user’s account, defaulting to the currently logged in user. These routes require authentication.

Users emails (usernames) are unique within the context of the associated app, but can be duplicated across the system. For example: gh@nsbasic.com can have accounts for helloworld.volt.live and testapp.volt.live.

Current User

Get user details
GET/api/user/{userid}

Returns JSON containing the user’s details.

Example URI

GET /api/user/DA6gHVdJ
URI Parameters
HideShow
userid
string (optional) Example: DA6gHVdJ

user to work with, defaults to the currently logged in user

Request
HideShow
Headers
Authorization: Bearer [Valid JWT]
Response  200
HideShow

Returns information about the user.

Headers
Content-Type: application/json
Body
{
  "id": "DA6gHVdJ",
  "email": "gh@nsbasic.com",
  "confirmed": true,
  "admin": true,
  "first_name": "George",
  "last_name": "Henne"
}
Response  401
HideShow

Returned if the authentication (JWT) is missing or invalid.

Response  404
HideShow

Returned if the user ID is not found (or the logged in user does not have access).

Response  422
HideShow

Returned if the user ID is undecodable.

Response  500
HideShow

Returned if there was a server error.

Update user details
PUT/api/user/{userid}

Allow any of the user details (including password) to be updated. Only passed attributes will be updated, however, if password is included, old_password and confirmation must also be included. The admin attribute (see above) is read-only and cannot be updated. The confirmed attribute is read-only and must be updated via the confirmation process. You must pass at least one property to be updated. Currently, you can only update your own user record.

Example URI

PUT /api/user/DA6gHVdJ
URI Parameters
HideShow
userid
string (optional) Example: DA6gHVdJ

user to work with, defaults to the currently logged in user

Request
HideShow
Headers
Content-Type: application/json
Authorization: Bearer [Valid JWT]
Body
{
  "email": "new@email.com",
  "password": {
    "old": "myOldPassword",
    "new": "myNewPassword",
    "confirmation": "myNewPassword"
  }
}
Response  200
HideShow

Returned if the update was successful. Returns the updated user object.

Body
{
  "id": "DA6gHVdJ",
  "email": "gh@nsbasic.com",
  "confirmed": true,
  "admin": true,
  "first_name": "George",
  "last_name": "Henne"
}
Response  401
HideShow

Returned if the authentication (JWT) is missing or invalid.

Response  403
HideShow

Returned if the old password is incorrect.

Response  404
HideShow

Returned if the user ID is not found or the logged in user does not have access.

Response  406
HideShow

Returned if the request’s Content-Type is not application/json.

Response  409
HideShow

Returned if the email is already in use by another user for the associated app.

Response  422
HideShow

Returned if the password and confirmation do not match, if there is a problem with the request body, or if the user ID is undecodeable. Also if the password is too weak.

Response  500
HideShow

Returned if there was a server error.

Delete account
DELETE/api/user/{userid}

Delete the account.

Example URI

DELETE /api/user/DA6gHVdJ
URI Parameters
HideShow
userid
string (optional) Example: DA6gHVdJ

user to work with, defaults to the currently logged in user

Request
HideShow
Headers
Authorization: Bearer [Valid JWT]
Response  204
HideShow

Returned if the account was deleted successfully (invalidating all tokens).

Response  401
HideShow

Returned if the authentication (JWT) is missing or invalid.

Response  404
HideShow

Returned if the user ID is not found or the logged in user does not have access.

Response  409
HideShow

Returned if the user has associated apps that must be deleted first.

Response  422
HideShow

Returned if the user ID is undecodable.

Response  500
HideShow

Returned if there was a server error.

Email Plug-in

© 2017 NS BASIC Corporation. All rights reserved.

In order to use this endpoint an API key and from address must be configured for the app in the Volt Dashboard. Currently, only SendGrid is supported as an underlying email provider.

Email Endpoint

Email Endpoint
POST/api/email

Send an email to the currently authenticated user.

Example URI

POST /api/email
Request
HideShow
Headers
Content-Type: application/json
Authorization: Bearer [Valid JWT]
Body
{
  "subject": "Thanks for signing up!",
  "text": "Dear User\nThanks for signing up!\n- App Owner"
}
Response  200
HideShow

Returned if the message was sent successfully.

Response  401
HideShow

Returned if the authentication (JWT) is missing or invalid.

Response  406
HideShow

Returned if the request’s Content-Type is not application/json.

Response  422
HideShow

Returned if the request JSON was invalid.

Response  500
HideShow

Returned if there was a server error.

Response  501
HideShow

Returned if email_from or email_api_key are not set (via the Dashboard).

Storage Plug-in

© 2017 NS BASIC Corporation. All rights reserved.

All calls include a scope (either an app or user ID at the moment). All calls include checks to make sure the user has access. Access currently falls under two scopes:

  • App Based - the app owner has read/write, app users have read. Useful for global app settings that can be public.

  • User Based - the user has read/write (app owner of course has read/write as well).

Keys length must be less than or equal to 255 characters.

Key based access

Retrieve
GET/api/storage/{scope}/key/{key}

Example URI

GET /api/storage/Q4VBZVgw/key/key
URI Parameters
HideShow
scope
string (required) Example: Q4VBZVgw

scope to use for storage requests

key
string (required) 

key to perform the action on

Request
HideShow
Headers
Authorization: Bearer [Valid JWT]
Response  200
HideShow

Returns valid JSON.

Headers
Content-Type: application/json
Body
"this is the value"
Response  401
HideShow

Returned if the authentication (JWT) is missing or invalid.

Response  404
HideShow

Returned if the scope or key is not found, or the user does not have access.

Response  422
HideShow

Returned if the scope can’t be decoded or if the key is too long.

Response  500
HideShow

Returned if there was a server error.

Create or Update
PUT/api/storage/{scope}/key/{key}

The body of this request should be valid JSON.

Example URI

PUT /api/storage/Q4VBZVgw/key/key
URI Parameters
HideShow
scope
string (required) Example: Q4VBZVgw

scope to use for storage requests

key
string (required) 

key to perform the action on

Request
HideShow
Headers
Content-Type: application/json
Authorization: Bearer [Valid JWT]
Body
"this is the value"
Response  204
HideShow

Returned if the create/update was successful.

Response  401
HideShow

Returned if the authentication (JWT) is missing or invalid.

Response  404
HideShow

Returned if the scope is not found or the user does not have access.

Response  406
HideShow

Returned if the request’s Content-Type is not application/json.

Response  422
HideShow

Returned if the scope can’t be decoded or if the key is too long.

Response  500
HideShow

Returned if there was a server error.

Delete
DELETE/api/storage/{scope}/key/{key}

Example URI

DELETE /api/storage/Q4VBZVgw/key/key
URI Parameters
HideShow
scope
string (required) Example: Q4VBZVgw

scope to use for storage requests

key
string (required) 

key to perform the action on

Request
HideShow
Headers
Authorization: Bearer [Valid JWT]
Response  204
HideShow

Returned if the deletion was successful or if there was nothing to delete.

Response  401
HideShow

Returned if the authentication (JWT) is missing or invalid.

Response  404
HideShow

Returned if the scope is not found or the user does not have access.

Response  422
HideShow

Returned if the scope can’t be decoded or if the key is too long.

Response  500
HideShow

Returned if there was a server error.

Miscellaneous Endpoints

Get all items
GET/api/storage/{scope}

Example URI

GET /api/storage/Q4VBZVgw
URI Parameters
HideShow
scope
string (required) Example: Q4VBZVgw

scope to use for storage requests

Request
HideShow
Headers
Authorization: Bearer [Valid JWT]
Response  200
HideShow

Returns all items stored in a JSON object or an empty object

Body
{
  "key1": "value1",
  "key2": "value2"
}
Response  401
HideShow

Returned if the authentication (JWT) is missing or invalid.

Response  404
HideShow

Returned if the scope is not found or the user does not have access.

Response  422
HideShow

Returned if the scope can’t be decoded.

Response  500
HideShow

Returned if there was a server error.

Clear all items
DELETE/api/storage/{scope}

Example URI

DELETE /api/storage/Q4VBZVgw
URI Parameters
HideShow
scope
string (required) Example: Q4VBZVgw

scope to use for storage requests

Request
HideShow
Headers
Authorization: Bearer [Valid JWT]
Response  204
HideShow

Returned if the deletion was successful, or if there were no items to delete.

Response  401
HideShow

Returned if the authentication (JWT) is missing or invalid.

Response  404
HideShow

Returned if the scope is not found or the user does not have access.

Response  422
HideShow

Returned if the scope can’t be decoded.

Response  500
HideShow

Returned if there was a server error.

Generated by aglio on 26 May 2017