Overview
The Flex5 Rest Api is in early access stage and under heavy development & evolution. This is our "private" Api that is being built for the Flex5 Phone, Tablet, & Desktop applications.
It is very likely we will build a "public" Api layer in the future with something like GraphQL. The reason is this Api is pretty low level with a flat JSON structure. This means you will have to make a lot of Api calls to get all the data that you need.
We envision a more public friendly Api in the future that allows external developers to better fetch data in a single request.
Api Terms & Conditions
Since this Api is under heavy development & evolution (and could get replaced with a "public" Api someday), we require that you sign off on an Api Terms & Conditions document.
You can find it here: https://docs.google.com/document/d/18m-saxs5foVA0JLp9N_7fmVEqFG1c1spZw8OC9wLEYs/edit
Download that document, and send to roger@flexrentalsolutions.com. Once it's received, you will be provided a special "source" property you will need to get authentication tokens.
Accessing Your Own Api Documentation
Our Api Documentation tool is Swagger UI. You can browse your own Swagger UI by using the template URL below.
Substitute in your own subdomain for "yourflexsite": https://yourflexsite.flexrentalsolutions.com/f5/swagger-ui.html
An Authentication Example With The Flex5 Dev Api
You can browse the cutting edge Api's from Flex Dev here: https://flex5dev.flexrentalsolutions.com/f5/swagger-ui.html
First Let's Get an Auth Token By Going Here: https://flex5dev.flexrentalsolutions.com/f5/swagger-ui.html#/Authentication/authenticationRequestUsingPOST
Post a JSON body something like below (substitute in your username/password). Notice the special "source" property, that is a special "key" that prevents unauthorized access to the Api. You will be provided this key in response to receiving signed terms & conditions document.
{ "username": "api-test", "password": "password", "source": "<will be provided>" }
{ "token": "eyJhbGciOiJIUzUxMiIsInppcCI6IkdaSVAifQ.H4sIAAAAAAAAAOVWTY_TMBD9LzkXq7vqUtobEhcOiL3ABXFw7WkyrGMHj5NuF_HfmaQfcbdOGsSRQxXVHr95fm9mkl8Z1ZtsnckK3wSgkM0y5UEG0Nn67mFxt1yuFvPVYjmfZQGstOEjb2RbA88PGhqOrsCXSITOUrb-1v0VlXc_QAUSDcLuGCO2yMcVSkPCg5JGXRwWaBuwwfl9fOi4p5wHURP497pEewJU_CullTkMIUUpYybtQQ0Gwumg2OCLq4h5o0KbJxj0mPBcOR_AX-63a9J0D8a9oHkWQztl63IDXrgGvEcNCWlSF1IlsQSW9Q9fmdnr3D23UqLtXFIp6LFbDTE4KYMlr1EsoIzueA3nvAJBRavKsD2jHoDGEOcjsIQBGxiqD1VIm8OjJNo5rxP3TyLEATLPPeQyMGQK_-DAp06etP1G7l194X7CooS_LTztKZb0JIfyTJm7JS3FjWoZ48or5Kw0-BJfuMMfELh0ujZwiRnLFzt2LnpmssX8ajmKvZJIudpeNVi_nXtXVzcan5QcdGDj3Y5AFKg1DAYdikn8rHnisdTn0k8MKx9qlrPNyMZ47K06Oti7RSC9KkRwT7yU7rOh4Lhi-4ES9884M2nMgDXdw6AKPJXJGZ5M0-7KiGK4zKXWwiYocyWD1dLf8C-RiRtrvKfETnooHL8m2nRlFShZwxs08Ij2c9VW_dms65gP0GA_Rtu24LHytDVux0KVPMEF8Lg19BfNFSeRdSiYPrc2v2q_UN9Q_1wI0w2eaMuQKFN0nSzctHfHyKD_f3T7Psv4I-Twefbu_v7tfPX7D4ARUHjGCQAA.tgbY7Wsje-qyiP99xfXSGtJ3-3JBOhpJUGnSRbwcsshrOIwbrEy7LcoQ7NSI4INxhyWo6hV6V3KzXyYE6uniqA", "user": { "id": "3820fee0-5fa1-11e8-bc43-12aef1b28bdc", "name": "Api Test", "userName": "api-test", "emailAddress": "api-test@flexrentalsolutions.com" } }
In Swagger, there is an AUTHORIZE button in the top right. Copy the token property, and paste your generated token there. Click Authorize, and now you can begin to play around with the other endpoints inside Swagger UI.
Writing Your Own Code
When you write code against the Api, the process will be similar'ish. You'll have to post to the auth endpoint to get a token and then send it down in the X-Auth-Token header for all requests.
If you're token is close to expiring the server will kick out a refresh token in the X-Auth-Token-Refreshed header. Our app just sniffs for the refresh token on each request, and if it finds one, it just replaces the current one and starts sending the new one.