API Reference
Sign Up
POST /api/signup
Parameters
type |
Description |
Example |
body |
User's email, password and your app's clientId |
{ "email": "user@example.com", "password": "ABCabc#$#$%123", "clientId": "yourClientId" }
|
Body Fields
field | type | required | example |
email | string | yes | example@example.com |
password | string | yes | ABCabc#$#$%123 |
clientId | string | yes | YOUR CLIENT ID |
Responses
Status Code |
Body Description |
Example |
What to do |
201 |
|
None |
Redirect user to the login page |
400 |
message : Invalid request |
{"message":"Invalid request"}
|
Check the request parameters |
500 |
message : Unknown API Error |
{"message": "Unknown API Error"}
|
Try again later. If issue persist, contact Pavillion |
Login
POST /api/login
Parameters
type |
Description |
Example |
body |
User's email, password and your app's clientId |
{ "email": "user@example.com", "password": "ABCabc#$#$%123", "clientId": "123e4567-e89b-12d3-a456-426614174000" }
|
Body Fields
field | type | required | example |
email | string | yes | example@example.com |
password | string | yes | ABCabc#$#$%123 |
clientId | string | yes | 123e4567-e89b-12d3-a456-426614174000 |
Responses
Status Code |
Body Description |
Example |
What to do |
200 |
id : the user id from Pavillion
email : the user's email
token : the JWT token to used in subsequent requests to Pavillion API |
{ "id": "xxx", "email": "xxx@xxx.com", "token": "JWT_TOKEN" }
|
set the Authorization header in subsequent requests to be:
Bearer {JWT_TOKEN} |
400 |
message : Invalid request |
{"message":"Invalid request"}
|
Check the request parameters |
401 |
message : Invalid credentials |
{"message":"Invalid credentials"}
|
User login failed, prompt them to login again |
500 |
message : Unknown API Error |
{"message": "Unknown API Error"}
|
Try again later. If issue persist, contact Pavillion |
Charge
POST /api/app/:YOUR_CLIENT_ID/charge
IMPORTANT: Only proceed with your service when you get a 200 response code from the charge endpoint. Otherwise you may not be able to charge the user.
Parameters
type |
Description |
Example |
path |
Your application's client ID |
123e4567-e89b-12d3-a456-426614174000
|
body |
Information used to charge the user |
{ "message": "{\"userInput\": \"hi\", \"userOutput\": \"How can I help?\"}", "userId": "123e4567-e89b-12d3-a456-426614174000", "chargeCents": 100, "currency": "USD" }
|
Body Fields
field | type | required | example |
message | string | no | "{\"userInput\": \"hi\", \"userOutput\": \"How can I help?\"}"
|
userId | string | yes | 123e4567-e89b-12d3-a456-426614174000 |
chargeCents | number | no | 100 |
currency | string | no (default to 'USD') | USD |
* Note: "message" and "chargeCents" cannot both be empty
Responses
Status Code |
Body Description |
Example |
What to do |
200 |
appMessageId : the id tracking the message sent to Pavillion |
{"appMessageId": "123e4567-e89b-12d3-a456-426614174000"}
|
Save the appMessageId in your database for reference later, or disregard it |
400 |
message : Invalid request |
{"message":"Invalid request"}
|
Check the request parameters |
402 |
message : Insufficient funds
appMessageId : the id tracking the message sent to Pavillion
chargeId : the id tracking the charge |
{ "message":"Insufficient funds", "appMessageId": "123e4567-e89b-12d3-a456-426614174000", "chargeId": "123e4567-e89b-12d3-a456-426614174000" }
|
Save the appMessageId and chargeId in your database for reference later. Ask users to recharge their account before resuming service. |
404 |
message : User {id} does not have an account in {currency} |
{"message":"User 123e4567-e89b-12d3-a456-426614174000 does not have an account in USD"}
|
Redirect user to Pavillion to create a new account in the currency required |
500 |
message : Unknown API Error |
{"message": "Unknown API Error"}
|
Try again later. If issue persist, contact Pavillion |